Outlook 2007 Addin: View and Edit Email Before Sending

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hello,

I am trying to capture emails before they are sent and view/edit the To,
CC, and BCC fields. I would also like to append a message to the bottom of
the message body.

I am trying to capture the 'Item' within the sub
'Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean)' and
convert the Item to a 'Outlook.MailItem'. That way, I believe that I can
view and edit these items.

How do I convert the 'Item' object into a 'MailItem' object? Here is my
code in VB:

Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As
Boolean) Handles Application.ItemSend
Dim mess As Outlook.MailItem
mess = Convert.ChangeType(Item, "Outlook.MailItem")
End Sub

Any help in VB or C# would be appreciated!!
 
C#:

Outlook.MailItem mess = (Outlook.MailItem)Item;

VB.NET:

Dim mess As Outlook.MailItem = CType(Item, Outlook.MailItem)
 
Back
Top