Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. Sub AutoReplywithTemplate(Item As Outlook.MailItem)
  2. Dim oRespond As Outlook.MailItem
  3.  
  4. ' Use this for a real reply
  5. ' Set oRespond = Item.Reply
  6.  
  7. ' This sends a response back using a template
  8. Set oRespond = Application.CreateItemFromTemplate("C:\path\to\template.oft")
  9.  
  10. With oRespond
  11. .Recipients.Add Item.SenderEmailAddress
  12. .Subject = "Your Subject Goes Here"
  13. .HTMLBody = "Your reply text goes here." & vbCrLf & _
  14. "---- original body below ---" & vbCrLf & _
  15. Item.HTMLBody & vbCrLf & _
  16. "---- Template body below ---" & _
  17. vbCrLf & oRespond.HTMLBody
  18.  
  19. ' includes the original message as an attachment
  20. .Attachments.Add Item
  21.  
  22. ' use this for testing, change to .send once you have it working as desired
  23. .Display
  24. End With
  25. Set oRespond = Nothing
  26. End Sub
  27.  
  28. Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
  29. Dim rrEID As Variant, varEID As Variant, olkItm As Object, olkAppointment As Outlook.AppointmentItem
  30. arrEID = Split(EntryIDCollection, ",")
  31. arrWords = Split(KILL_WORDS, ",")
  32. For Each varEID In arrEID
  33. Set olkItm = Session.GetItemFromID(varEID)
  34. If olkItm.Class = olMeetingRequest Then
  35. Set olkAppointment = olkItm.GetAssociatedAppointment(False)
  36. If DatePortion(olkAppointment.Start) = DatePortion(olkAppointment.End) Then
  37. If TimePortion(olkAppointment.Start) <= #2:15:00 PM# And TimePortion(olkAppointment.End) >= #3:00:00 PM# Then
  38. olkAppointment.Respond olMeetingDeclined
  39. End If
  40. End If
  41. End If
  42. Next
  43. End Sub
  44.  
  45. Function DatePortion(datValue As Date) As Date
  46. DatePortion = Format(datValue, "dd/mm/yyyy")
  47. End Function
  48.  
  49. Function TimePortion(datValue As Date) As Date
  50. TimePortion = Format(datValue, "hh:mm:ss")
  51. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement