View Single Post
  #2  
Old May 31st 12, 11:08 PM
NDuarte NDuarte is offline
Junior Member
 
First recorded activity at Outlookbanter: May 2012
Posts: 6
Default

The following is a way to accomplish what you are looking for. Do note that the sections that have "int_Temp - #" may have to be adjusted based on the actual form received. What it is doing is subtracking the spaces from the end of the array which may be more or less than the actual e-mail you are getting. Just play with it to get it right. In order to get the code to work you are going to have to setup a rule to run it when an e-mail with the proper subject comes in (I am assuming that the subject is autopopulated for the form).

Code:
Public Sub AutoReply(oMailItem As Outlook.MailItem)
  Dim oMail As Outlook.MailItem
  Dim str_FirstName
  Dim str_LastName
  Dim str_Email As String
  Dim str_Date
  Dim str_Time
  Dim arr
  Dim int_Temp As Integer
  Dim str_Body As String

  On Error Resume Next

  arr = Split(oMailItem.Body, ":")
  
  
  int_Temp = Len(arr(6))
  str_FirstName = Mid(arr(6), 2, int_Temp - 13)
    
  int_Temp = Len(arr(7))
  str_LastName = Mid(arr(7), 2, int_Temp - 16)
  
  int_Temp = Len(arr(8))
  str_Email = Mid(arr(8), 2, int_Temp - 17)
  
  int_Temp = Len(arr(9))
  str_Date = Mid(arr(9), 2, int_Temp - 25)
  
  int_Temp = Len(arr(12))
  str_Time = arr(10) & ":" & arr(11) & ":" & Mid(arr(12), 1, int_Temp - 10)
  
  str_Body = "Thank you " & str_FirstName & " " & str_LastName & " for your request for an appointment on " & str_Date & " at" & str_Time & " ... yadda yadda, blah blah."

'Create a new mail item
Set oMail = Application.CreateItem(olMailItem)

'Set the proper fields of the e-mail and send it
With oMail
  .To = oMailItem.SenderEmailAddress
  .Subject = " " & oMailItem.Subject
  .Body = str_Body
  
  '.Display
  .Send
End With


End Sub
Ads