Guest User

Untitled

a guest
Jan 18th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. Sub CalendarInvite()
  2.  
  3. Dim Rng As Range, strFileName As String, strRecipient As String
  4. Dim strSubject As String, strBody As String
  5. Set myoutlook = CreateObject("Outlook.Application")
  6.  
  7. For Each Rng In Range("tblData[Status]")
  8. If Rng = "To be Sent" Then
  9.  
  10. Set myapt = myoutlook.CreateItem(olAppointmentItem)
  11. strSubject = Cells(Rng.Row, Range("tblData[Subject]").Column)
  12. strFileName = "C:UsersTestDownloadsCalendarInvites" & _
  13. Cells(Rng.Row, Range("tblData[Email]").Column) & ".ics"
  14. strRecipient = Cells(Rng.Row, Range("tblData[Email]").Column)
  15. strBody = "Test Mail Body"
  16. With myapt
  17. .MeetingStatus = olMeeting
  18. .Subject = " Wedding Reception - Ramya & Mohan "
  19. .Location = " PJN Mahal, #10, Egabaram Salai, Udaya Nagar, Porur, Chennai 116 "
  20. .Start = "28-12-2013 07:00 PM"
  21. .Duration = 150
  22. .AllDayEvent = "False"
  23. .BusyStatus = "2"
  24. .ReminderSet = True
  25. .ReminderMinutesBeforeStart = 2880
  26. .ResponseRequested = True
  27. .Body = strBody
  28. End With
  29.  
  30. Set myRequiredAttendee = myapt.Recipients.Add(strRecipient)
  31. myRequiredAttendee.Type = olRequired
  32.  
  33. With myapt
  34. .SaveAs strFileName, olICal
  35. .Delete
  36. End With
  37.  
  38. Set mymail = myoutlook.CreateItem(olMailItem)
  39. With mymail
  40. .To = strRecipient
  41. .Subject = strSubject
  42. .Body = strBody
  43. .Importance = olImportanceHigh
  44. .ReadReceiptRequested = True
  45. .Attachments.Add strFileName
  46. If Cells(Rng.Row, Range("tblData[Attachment]").Column) = "Yes" Then
  47. mymail.Attachments.Add "D:Directions-PJNMahal.jpg"
  48. End If
  49. .Send
  50. End With
  51.  
  52. Rng = "Sent, Subject to Delivery"
  53.  
  54. End If
  55. Next Rng
  56.  
  57. End Sub
Add Comment
Please, Sign In to add comment