Idea for automatically convert emails into an outlook calendar item - Event managing

Permalink
So. I've come up with an idea to convert an incoming email in outlook into an outlook appointment item. This could come in handy when someone has an event management extension or something like that.

When an order confirmation email is incoming in outlook, there is somewhere in the body the chosen date and time. At this point I'm trying to grab that date and time, and put it in the appointment item. So everything will be automatic.

Customer orders/reserves -> Order confirmation email -> email converted to appointment

This can be done with macro’s in outlook. But this (Visual Basic) isn't my strength. Can someone maybe help me with this?

Link 1:http://www.slipstick.com/developer/code-samples/create-outlook-appo...
Link 2:http://www.slipstick.com/outlook/rules/create-task-email-rule/...

FischerVision
View Replies:
jatin replied on at Permalink Reply
Hi FischerVision

I am trying to achieve same thing. Can you please provide me some details How did you achieve this?
FischerVision replied on at Permalink Reply
FischerVision
Hi jatin,

Yes I've managed to get this working.. I'll post the code later this day.
FischerVision replied on at Permalink Reply
FischerVision
**Edited: Removed 2 errors in the code - And the dates are DD-MM-YYYY**
So I've this at the moment:
Sub CreateAppt(Item As Outlook.MailItem)
Dim newOrder As Outlook.MailItem
Dim thebody As String, date As Date, strdate As String, time As String, address As String
Dim TI As AppointmentItem
thebody = Item.Body
strdate = Mid(thebody, InStr(1, thebody, "date: ") + 6, _
InStr(InStr(1, thebody, "date: "), thebody, vbCrLf) - _
InStr(1, thebody, "date: ") - 6)
date = DateSerial(Split(strdate, "/")(2), _
Split(strdate, "/")(1), _
Split(strdate, "/")(0))
time = Mid(thebody, InStr(1, thebody, "time: ") + 6, _
InStr(InStr(1, thebody, "time: "), thebody, vbCrLf) - _
InStr(1, thebody, "time: ") - 6)
address = Mid(thebody, InStr(1, thebody, "address: ") + 9, _


It's pretty straight forward from here. When outlook gets a message like this:
date: 10/03/2015
time: 20:00
address: streetname 1

It will make an outlook appointment with the date and time given.
Let me know!
jatin replied on at Permalink Reply
Hi FischerVision

Thanks for a quick reply and code.
I have run that code and tried sending message with same instruction you gave but no luck.
Here is the code I tried:

Sub CreateAppt(Item As Outlook.MailItem)
Dim newOrder As Outlook.MailItem
Dim thebody As String
Dim date1 As Date
Dim strdate As String
Dim time As String
Dim address As String
Dim TI As AppointmentItem
thebody = Item.Body
strdate = Mid(thebody, InStr(1, thebody, "date1: ") + 7, _
InStr(InStr(1, thebody, "date1: "), thebody, vbCrLf) - _
InStr(1, thebody, "date1: ") - 7)
Date = DateSerial(Split(strdate, "/")(2), _
Split(strdate, "/")(1), _
Split(strdate, "/")(0))
FischerVision replied on at Permalink Reply
FischerVision
Hi Jantin,

I missed your reply, did you get it to work?
icefrog replied on at Permalink Reply
Hello Fisch,

I have a request i would need assistance with. So based on your code. I want to created a calendar appointment using these variable in my email. Below is what i want to achieve. Can you assist me with the vb script.


********** email subject from my email ************
Booking Confirmed for ABC LLC

********* content in the email body ************
Client: ABC LLC
Project: ABC - cisco network deployment
Booking Start: 09/05/2015
Booking End: 09/08/2015
Booking type:Confirmed Remote
Hours Booked: 2.00

********* what i want to achieve ***************
basically i want to create an appoint in my calendar using the following variable

.Subject of my appointment = Project (cisco network deployment)
.Location = Booking type (Confirmed Remote)
.Start = (Booking Start) and (Booking End)
.Duration = Hours Booked
.Body = Item.Body
.ReminderMinutesBeforeStart = 15

Any help would be greatly appreciated

*Edwin*
FischerVision replied on at Permalink Reply
FischerVision
Hi Icefrog,

I don't understand it completely. What you want to create an appointment that expands over serveral days but for just 2 hours? That doesn't add up, how should this work?
icefrog replied on at Permalink Reply
Hello Fischer,

Basically I wanted to create an appointment using these parameter an incoming email. Below are the parameter in one of my emails

********** email subject ************
Booking Confirmed for ABC LLC

********* content in the email body ************
Client: ABC LLC
Project: ABC - cisco network deployment
Booking Start: 09/05/2015
Booking End: 09/08/2015
Booking type:Confirmed Remote
Hours Booked: 2.00

********************** what i want to achieve ***********************
So I want outlook to use the content in the email to automatically created a calendar event.
where :

the subject of the calendar event will be the same name as the description in Project ( ABC - cisco network deployment )

the location of the calendar event will be the same name as the description in Booking type: (Confirmed Remote)

the start time of the calendar event will be the value in Booking Start:

the end time of the calendar event will be the value in Booking End:

the duration of the calendar event will be the value in Hours Booked ( in this case 2.00 )

the reminder for the calendar event will be 15min

what do you think?

*icefrog*
FischerVision replied on at Permalink Reply
FischerVision
Well you're missing the time I guess. For an appointment it needs to have a date and time, and you only have the start- and end-date. The hours that it is booked is the duration of the event. So where should the appointment have to appear in the calendar? But I don't know exactly how it turns out when the events is on several days, so you'll just have to play a little bit with it... But in the code that I posted is stated the DateSerial. Note that in my e-mails and code the date is programmed like DD-MM-YYYY.
And your date is MM-DD-YYYY, so try the following:

Turn this
date = DateSerial(Split(strdate, "/")(2), _
Split(strdate, "/")(1), _
Split(strdate, "/")(0))


into this
date = DateSerial(Split(strdate, "/")(2), _
Split(strdate, "/")(0), _
Split(strdate, "/")(1))


and remove the time maybe, see how it works
icefrog replied on at Permalink Reply
I guess for the time I would want all appointment to start 9am EST and end at 5pm EST to make it simple. That means all my appointment will have a duration of 8hrs. Does that help?

*icefrog*
FischerVision replied on at Permalink Reply
FischerVision
You could try the following, note that I put a start time in the e-mail:

The incoming mail:
********** email subject from my email ************
Booking Confirmed for ABC LLC

********* content in the email body ************
Client: ABC LLC
Project: ABC - cisco network deployment
Booking Start: 09/05/2015
Booking Start Time: 09:00
Booking End: 09/08/2015
Booking type:Confirmed Remote
Hours Booked: 2.00

********* what i want to achieve ***************
basically i want to create an appoint in my calendar using the following variable

.Subject of my appointment = Project (cisco network deployment)
.Location = Booking type (Confirmed Remote)
.Start = (Booking Start) and (Booking End)
.Duration = Hours Booked
.Body = Item.Body
.ReminderMinutesBeforeStart = 15

The code:
Sub CreateAppt(Item As Outlook.MailItem)
Dim newOrder As Outlook.MailItem
Dim thebody As String, date As Date, strdate As String, time As String, address As String, projectname As String, date1 As Date, strdate1 As String
Dim TI As AppointmentItem
thebody = Item.Body
projectname = Mid(thebody, InStr(1, thebody, "Project: ") + 9, _
InStr(InStr(1, thebody, "Project: "), thebody, vbCrLf) - _
InStr(1, thebody, "Project: ") - 9)
strdate = Mid(thebody, InStr(1, thebody, "Start: ") + 7, _
InStr(InStr(1, thebody, "Start: "), thebody, vbCrLf) - _
InStr(1, thebody, "Start: ") - 7)
date = DateSerial(Split(strdate, "/")(2), _
Split(strdate, "/")(0), _
Split(strdate, "/")(1))
strdate1 = Mid(thebody, InStr(1, thebody, "End: ") + 5, _


Note 1: I don't know how the end time is put in the fields in outlook, so it could be the end of the day or the beginning of the day. You should check that out.
Note 2: I don't know how the duration is measured, in hours or in minutes. So play a little bit with that.

Also, remove the notes from the code of course.

Play with it and let me know!