Rick Goud
Guest
|
Hi,
I want to be able to change to subject, senders and body of an email after being sent. I want to do so because, in the ItemSend event I want to change the recipient to another address to verify whether it was allowed to send this message, but in the SentItems mailbox I want the mail to show as if it was sent to the original recipients and add ' (checked by administrator)' in the subject and also include a message in the body.
However in the ItemAdd I am able to get the sent mail, but when I try to change the subject eg nothing really changes in the sent items folder but also no exception is thrown.
The code i use in the ItemSend method is:
if (item is Outlook.MailItem)
{
Outlook.MailItem sentmail = (Outlook.MailItem)item;
sentmail.Subject += " Protected by ZIVVER";
sentmail.HTMLBody += "test";
if (sentmail != null) Marshal.ReleaseComObject(sentmail);
}
The method is called (checked via break in Visual Studio and via a messagebox).
I tried a work around by trying to make a copy of the mail being sent in the ItemSend event, but it appears that no copy of a mail can be made during sendinG?
Any idea's on how to do this in c#? Or a workaround that will do the same as I intend?
Thanks in advance!
Rick |
|
Andrei Smolin
Add-in Express team
Posts: 18826
Joined: 2006-05-11
|
Hello Rick,
I suppose this occurs because you release the COM object that you retrieved using e.Item while you must never release COM objects obtained through the parameters of events provided by Add-in Express. If this doesn't help, you can try to save the item. Also, sentmail.HTMLBody += {a string} actually adds the string to a well-formed markup and this may break the markup.
Andrei Smolin
Add-in Express Team Leader |
|