karthik80c
asked on
How to get the date mentioned in the email into the VBA script in Outlook??
In outlook, I have created a rule that executed when I receive mail and it will create the appointment on outlook calendar with details from the mail. In that I need to get the date and time mentioned in the mail body as the date of appointment created in outlook calendar.
ASKER
Mail Body:
Here I need to use the Inspection date and time.
Transaction Name: 104 Horne Street
Contact Name: Wade Short
Email:
Phone: 0409696155
Inspection Date: 14-Aug-2015 18:30:00
Outcome Result:
meetingRequest.Categories = email.Categories
meetingRequest.body = email.body
meetingRequest.Subject = email.Subject
meetingRequest.Location = email.Subject
meetingRequest.Start =
meetingRequest.Duration = 60
meetingRequest.ReminderMinutesBeforeStart = 45
meetingRequest.ReminderSet = True
Here I need to use the Inspection date and time.
See example
Sub macro2()
itemBody = "Transaction Name: 104 Horne Street" & vbCrLf & _
"Contact Name: Wade Short" & vbCrLf & _
"Email:" & vbCrLf & _
"Phone: 0409696155" & vbCrLf & _
"Inspection Date: 14-Aug-2015 18:30:00" & vbCrLf & _
"Outcome Result:"
aText = Split(itemBody, vbCrLf)
aTextTmp = Filter(aText, "Inspection Date:")
aInspDate = Split(aTextTmp(0), " ")
dtInspDate = DateValue(aInspDate(2))
dtInspTime = TimeValue(aInspDate(3))
End Sub
ASKER
It shows compiler error as "Expected Array" in line 12, 13, 14 on the above code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried the following code to assign date and time, it tooks the date but not time.
Instead of above i try the following, it works good.
I need the help in time part.
meetingRequest.Start = dtInspDate + dtInspTime
Instead of above i try the following, it works good.
meetingRequest.Start = dtInspDate + #11:00:00 AM#
I need the help in time part.
pls try to add the two thing before assigning to start
dtInspDateTime = dtInspDate + dtInspTime
meetingRequest.Start = dtInspDateTime
dtInspDateTime = dtInspDate + dtInspTime
meetingRequest.Start = dtInspDateTime
ASKER
I tried the above code, but it doesn't work.
Could you show me the result of the to msgboxes
dtInspDateTime = dtInspDate + dtInspTime
MsgBox dtInspDateTime
myItem.Start = dtInspDateTime
MsgBox myItem.Start
dtInspDateTime = dtInspDate + dtInspTime
MsgBox dtInspDateTime
myItem.Start = dtInspDateTime
MsgBox myItem.Start
ASKER
then try
aInspDate = Split(aTextTmp(0), ": ")
dtInspDate = DateValue(aInspDate(1))
dtInspTime = TimeValue(aInspDate(1))
MsgBox dtInspDate & vbCrlf & dtInspTime
dtInspDateTime = dtInspDate + dtInspTime
MsgBox dtInspDateTime
myItem.Start = dtInspDateTime
aInspDate = Split(aTextTmp(0), ": ")
dtInspDate = DateValue(aInspDate(1))
dtInspTime = TimeValue(aInspDate(1))
MsgBox dtInspDate & vbCrlf & dtInspTime
dtInspDateTime = dtInspDate + dtInspTime
MsgBox dtInspDateTime
myItem.Start = dtInspDateTime
ASKER
it shows Type mismatch error
it depends how the mail boy is constructed and will it always stay the same
EDIT could you send a dummy email body
Regards