I am learning VBA, but for the time being I am not that good and I found this macro:
Scheduled and recurring email in Outlook?
It sends an email thanks to a scheduled appointment set in the calendar.
Could someone maybe help me complete it so that it is possible to have an option to send an attachment too?
[EDIT] This is the script I modified, but it still does not work.Could you please just give me an indication?
Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
Dim myAttachments As Outlook.Attachments
Set objMsg = Application.CreateItem(olMailItem)
Set myAttachments = objMsg.Attachments
If Item.MessageClass <> "IPM.Appointment" Then
Exit Sub
End If
If Item.Categories <> "Blue Category" Then
Exit Sub
End If
objMsg.To = Item.Location
objMsg.Subject = Item.Subject
objMsg.Body = Item.Body
myAttachments.Add "C:\Test.txt", _
objMsg.Send
Set objMsg = Nothing
End Sub
I think the problem is that the attachment is defined as something linked to Outlook whereas the MailItem was not. The macro worked well before inserting the few lines about the attachment, now it does not even send a mail anymore.