Removing outlook attachment from Word code
Hello everyone,
I am working on a project which is in Word. The project involves creating an Outlook mail message from Word and attaching the current word document as a PDF attachment. After the message has been sent, the attachment must be removed from the message otherwise it causes space issues for the mailbox on the server. I am able to remove the attachment by accessing the Sent Items folder.
However, my problem is, once the email message has been created, the code in word is not able to listen to the events happening with the message. So, for example, if the user decides to cancel the message, my word code has no idea that cancel has been pressed and it still keeps searching in the Sent Items folder in the hope that the message will sooner or later turn up. If after a set period of time (say 2 minutes) the message still hasn't appeared in the Sent Items folder, the code will give up. But this delay is causing word to be unavailable during that time period and is causing frustration for users. Can anyone give some ideas about how to trap the events of Outlook from Word?? I could do it from Outlook but I don't know how to let Outlook just trust my code and not run any viruses.
Thanks in Adv.
Re: Removing outlook attachment from Word code
There is no need to do it from Word. You can create a Items_Add event for the SentItems folder in Outlook. Then whenever a email is sent from Word with a certain subject or attachment name or all attachments can be removed at that time from within Outlook. ;)
Re: Removing outlook attachment from Word code
Thanks for your reply, RobDog888. But how can I tell Outlook to trust only my code because I don't want to set security of Outlook to low in order to allow my code to run.
Re: Removing outlook attachment from Word code
You only need to set the security to Medium - allow the user to choose to run macros or not. If you want to put it to High and have it still run then you can look at my CodeBank thread on Creating Digital Signatures and signing VBA projects. ;)