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.
karthik80cAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

it depends how the mail boy is constructed and will it always stay the same

EDIT could you send a dummy email body

Regards
0
karthik80cAuthor Commented:
Mail Body:


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

Open in new window


Here I need to use the Inspection date and time.
0
Rgonzo1971Commented:
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

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

karthik80cAuthor Commented:
It shows compiler error as "Expected Array" in line 12, 13, 14 on the above code.
0
Rgonzo1971Commented:
then try

Sub macro2()
Dim aText As Variant, aTextTmp As Variant, aInspDate As Variant
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(1))
dtInspTime = TimeValue(aInspDate(1))

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
karthik80cAuthor Commented:
I tried the following code to assign date and time, it tooks the date but not time.

meetingRequest.Start = dtInspDate + dtInspTime 

Open in new window


Instead of above i try the following, it works good.

meetingRequest.Start = dtInspDate + #11:00:00 AM# 

Open in new window


I need the help in time part.
0
Rgonzo1971Commented:
pls try to add the two thing before assigning to start

dtInspDateTime = dtInspDate + dtInspTime
meetingRequest.Start = dtInspDateTime
0
karthik80cAuthor Commented:
I tried the above code, but it doesn't work.
0
Rgonzo1971Commented:
Could you show me the result of the to msgboxes

dtInspDateTime = dtInspDate + dtInspTime
MsgBox dtInspDateTime
myItem.Start = dtInspDateTime
MsgBox myItem.Start
0
karthik80cAuthor Commented:
-35428917886799ACB92C2D54F435A456592.jpg
I got only one msgbox. Then it shows Type mismatch error on "meetingRequest.Start = dtInspDateTime"
0
Rgonzo1971Commented:
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
0
karthik80cAuthor Commented:
it shows Type mismatch error
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.