Outlook 2010 Macro, sets Start date flag based on text in body of e-mail

BITASCII
BITASCII used Ask the Experts™
on
Hi, SQL server sends e-mail each time a meeting reservation is confirmed. On some line in body of e-mail the label 'Meeting Start:'  appears on a new line, always after a blank line.  That label is followed by meeting start date information in the format mm/dd/yyyy.  2 examples are pasted below - disregard any time info, we are only interested in start date.

Does anyone know how in Outlook 2010 a vba macro can grab the date in body of above mentioned e-mail, set flag and set the Start date same as date in body of e-mail?

Here is how the sart date appears in body of e-mail -- first the blank line, then Meeting Start label, followed by date ...

Meeting Start:    11/16/2010 2:00:00 PM

Meeting Start:         5/17/2011 11:00:00 AM (Eastern Standard Time)

Appreciate any thoughts/solutions.  Volume of generated e-mails is up, a macro to set flag and start date would eliminate number of user errors.  Thanks :-)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
Any mail that comes in with this format to raise a calendar appointment of the same?  If so it ought to be doable, potential concerns would be for example re-arranged meetings and/or cancellations.

Chris
BITASCIIAV Technology Support

Author

Commented:
Hi Chris,  Appreciate your response very much!  Just to clarify, we are not looking to set a calendar appointment (that would get us into all the issues you point out above, and how right you are!), ... what we want is to set vlaue of 'start date' in the 'custom flag' for that e-mail.  

To display the 'custom flag' screen use shortcut (Ctrl+Shift+G)  - in open, or selected OL201 e-mail.

At heart of the original post is this string to date conversion question: can vba reliably convert a string found in body of e-mail so as to set date value of 'start date' in 'custom flag'?  

Screen shot attached shows e-mail with date string in body of e-mail, and start date field in custom flag, ... set manually.  Can vba replace that manual step? Can vba use date string in body, to set start date in custom flag?
Software Quality Lead Engineer
Top Expert 2011
Commented:
Insert the following code into a normal code module and then set up a rule running on all received mails it needs to run a script and navigate to the Q_27042035

Chris
Sub Q_27042035(mai As MailItem)
Dim str As Variant
    
    If mai.Class = olMail Then
        str = Split(mai.body, "Meeting Start:", , vbTextCompare)
        If UBound(str) >= 1 Then
            str = Split(Trim(Replace(str(1), Chr(160), " ")), " ")
                If IsDate(str(0)) Then
                    With mai
                        .FlagIcon = olRedFlagIcon
                        .FlagRequest = "Follow up"
                        .FlagStatus = olFlagMarked
                        .MarkAsTask olMarkNoDate
                        .TaskStartDate = str(0)
                        .Save
                    End With
                End If
        End If
    End If
    
End Sub

Open in new window

BITASCIIAV Technology Support

Author

Commented:
Chris, Works better than expected!  Very tight code, Sir!  Thanks much :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial