Attach file on send in Outlook
Posted on 2013-01-15
I need a macro to attach a file when the user clicks on send. There are criteria involved: 1. Do not attach the file if the recipient is internal, ie. on the domain and 2. Do not attach the file if the recipient has already been sent an email already that day/week etc.
I have found the following:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Const strFile = "C:\MyAdvert.pdf"
If Item.Class = olMail Then
'if file doesn't exist then do nothing
If Not Dir(strFile, vbDirectory) = vbNullString Then
This only checks that the pdf file exists but I also need to check the recipient to see if an email has already been sent to that recipient(s) on that day, and if so, send the email without the attachment. Also if the user is internal to the Exchange (2007) system then never attach the pdf file.
If there are several users and all are internal then don't attach. If only one is external then attach the file. Outlook versions 2003/2007 are being used.