Consulting

Results 1 to 2 of 2

Thread: Create an Appointment from using email contents

  1. #1

    Create an Appointment from using email contents

    Ok - I am stumped and cannot find information anywhere on this matter - your help is greatly appreciated.

    I have a web based program that autmatically generates an email with the following information...

    To: John Doe

    John Doe has assigned you the following new task:

    Subject: Call
    Guest: John Smith
    Due Date: 2/28/2012
    Priority: Normal
    Comments: Help Me

    For more details, click the following link:

    linkgoeshere

    ------------------------
    I have a rule set that will run "the script" on every email from the sender and..

    I need the script that will grab the Guest name from the body and copy it to the subject and copy the Due date from the body to the Start and End date of the appointment. Time can be 10:00 am.
    Thank you for the help!

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    [vba]Sub Task_from_Email()
    'Using outlook 2010.
    'Mailmessage we are going to handle
    Dim mymessage As Outlook.MailItem
    'thebody = message, thesubject = subject, thedate = datevalue, strdate = stringdate
    Dim thebody As String, thesubject As String, thedate As Date, strdate As String
    'taskitem
    Dim TI As TaskItem
    'put mailmessage into mymessage. we use the active mailmessage in this example
    Set mymessage = ActiveExplorer.Selection.Item(1)
    'put body of message in thebody
    thebody = mymessage.Body
    'extract the parts we want
    thesubject = Mid(thebody, InStr(1, thebody, "Subject: ") + 9, _
    InStr(InStr(1, thebody, "Subject: "), thebody, vbCrLf) - _
    InStr(1, thebody, "Subject: ") - 9)
    thesubject = thesubject & " " & _
    Mid(thebody, InStr(1, thebody, "Guest: ") + 7, _
    InStr(InStr(1, thebody, "Guest: "), thebody, vbCrLf) - _
    InStr(1, thebody, "Guest: ") - 7)
    strdate = Mid(thebody, InStr(1, thebody, "Due Date: ") + 10, _
    InStr(InStr(1, thebody, "Due Date: "), thebody, vbCrLf) - _
    InStr(1, thebody, "Due Date: ") - 10)
    'little display, can be omitted
    MsgBox "Action required : " & vbCrLf & thesubject & vbCrLf & "Due date : " & strdate
    'the date format used is m/d/yyyy I presume
    'dateserial needs the year first, then the month and ends with day
    thedate = DateSerial(Split(strdate, "/")(2), _
    Split(strdate, "/")(0), _
    Split(strdate, "/")(1))
    'create task
    Set TI = Application.CreateItem(olTaskItem)
    With TI
    .Subject = thesubject
    .Body = mymessage.Body
    .StartDate = thedate
    .DueDate = thedate
    'the space before the hour is needed. Don't ask me why.
    .ReminderTime = .DueDate & " 10:00"
    .ReminderSet = True
    .Save
    '.Display
    End With
    End Sub
    [/vba]Charlize

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •