2
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.
2
Welcome so SU! We're not a script writing service. What have you got/tried so far, and where are you getting stuck exactly? Have you checked with MSDN yet? Perhaps starting with this: Attachments.Add Method (Outlook)
– Ƭᴇcʜιᴇ007 – 2014-09-12T19:35:27.140Thanks, I have tried to combine it with http://msdn.microsoft.com/en-us/library/office/ff869553%28v=office.15%29.aspx, but it did not work since I am only a beginner in VBA. (Did not click on your link, it turns out to be the same)
– Nre – 2014-09-12T19:39:48.4271Ok, since we can't read your mind, please edit your question and post the code you have created in attempts to use the Attachments. :) Also include/describe the results of your code, and/or any run-time errors you're encountering. – Ƭᴇcʜιᴇ007 – 2014-09-12T19:41:31.710
Sorry I did not post the script, since I did (almost) no changes and I guess it is a matter of one line I thought it was not relevant. You are all doing a great job here, please excuse me if my first post was not well understood. – Nre – 2014-09-12T23:35:40.543