C# Outlook COM Add-in

T

Tarran

Hi All,

I'm trying to figure out how to make a C# COM Add-in that runs whenever all
emails are sent - collects all receipent address then cross checks email
address with our customer database then futher processing applied.

I've already made an Outlook COM Add-in using C# which runs when the added
button is click however I am trying take it futher so runs after an email is
sent.

I'm thinking I can do this by adding a rule that runs a "Custom Action"
after all email is sent; however I don't know how to have my COM Add-in show
in the "Custom Action" list in outlook 2003.

Does anyone know how I can accomplish this either with custom action or
some-other way... I'm open to suggestions. Has anyone seen any tutorials or
examples.

All feedback is appreciated. Many Thanks
Tarran
 
K

Ken Slovak - [MVP - Outlook]

Two ways to do what you want. You can either trap the send at the item level
by instantiating a class to track open Inspectors and handle the item events
for Inspector.CurrentItem (including Item.Send). You'd instantiate that in
the NewInspector event. See
http://www.outlookcode.com/codedetail.aspx?id=797 for an example of that
where the wrapper allows you track multiple open items.

The alternative is to handle things on an application-wide level by handling
Application.ItemSend.
 
T

Tarran

Hi Ken,

Thanks so much for your help - Sounds like what I am after!!

I'll give it ago and let you know how things work out.

Many Thanks,
Tarran
 
T

Tarran

Hi Ken,

Thanks for your help - Thats exactly what I was after.

I added to a Event Handler to Application.ItemSend and all working as planned.

However; How can I collect the To address from the email that was sent?

Many Thanks,
Tarran
 
K

Ken Slovak - [MVP - Outlook]

Have you looked at the .To property? The Object Browser is your friend if
you are looking for properties, methods or events that are available to you.

To and the Recipients collection would be restricted in the object model
security unless you're running as a trusted COM addin or using a library
that bypasses the security such as Redemption (www.dimastr.com/redemption).
 
T

Tarran

Hi Ken,

Thanks for your help.

I've tried using the .To property in my ItemSend event handler but I'm sure
I appling it the wrong way. How should I be doing it?

private void applicationObject_ItemSend(object Item, ref bool Cancel)
{
Microsoft.Office.Interop.Outlook._MailItem OutlookMail =
(Microsoft.Office.Interop.Outlook._MailItem)applicationObject.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
System.Windows.Forms.MessageBox.Show(OutlookMail.To, "Heading");
}

Many Thanks,
Tarran
 
K

Ken Slovak - [MVP - Outlook]

At that point, before the mail is actually sent you might have to deal with
the Recipients collection and check each Recipient for Type, as Sue
suggested. If Type = olTo you have a To Recipient.
 
T

Tarran

Thanks for your help - I've sorted it.

Ken Slovak - said:
At that point, before the mail is actually sent you might have to deal with
the Recipients collection and check each Recipient for Type, as Sue
suggested. If Type = olTo you have a To Recipient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top