none
Outlook 2010 Intercept Send Email RRS feed

  • Question

  • Hi Everyone, i have a question. I am using Microsoft Outlook 2010 and Visual Studio 2010 VB.

    i need a add in that can intercept the user from sending an email. after intercepting, i will take in the email message data, recipients' email, date time and the attachments and store the data into the database.

    Also, i will store the attachment files and store it into my harddisk.

     

    Please help. I have never use outlook before. so i don't know how to start

    Tuesday, November 29, 2011 9:42 AM

All replies

  • You can create an Outlook COM add-in that intercepts the Application.ItemSend event.

    The MailItem being sent will be passed to your event handler as an argument.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Tuesday, November 29, 2011 2:11 PM
  • can you explain to me how to do it? sorry i have no experience so i don't know how to do so.

     

    Or is there a tutorial or something to do so?

    Wednesday, November 30, 2011 12:56 AM
  • Start with http://www.outlookcode.com
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Wednesday, November 30, 2011 1:00 AM
  • thanks i will look into the website..

     

    i would like to ask.

     

    how can i intercept the send button. and i will retrieve out the email's message, recipient email? and i will store the data into my database.

    • Edited by noobie1 Wednesday, November 30, 2011 3:21 AM
    Wednesday, November 30, 2011 3:15 AM
  • Again, use Application.ItemSend event.

    The MailItem being sent will be passed to your event handler as an argument.

    The mesage recipients can be accesed using the MailItem.Recipients collection. Have a look at an existing message with OutlookSpy (click the Item button). 


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Wednesday, November 30, 2011 5:03 PM
  • i have tried to display out the data in a msgbox.

     MsgBox("Subject:" + mail.Subject + vbCrLf + "Recipient:" + mail.To + vbCrLf + DateTime.Now)

    but how do i get the sender email address? i tried

    MsgBox(mail.SenderEmailAddress)

    but it does not display anything.

    also how do i display the attachment name without the attachment type. eg.doc or .jpg

    • Edited by noobie1 Thursday, December 1, 2011 3:07 AM
    Thursday, December 1, 2011 12:36 AM
  • Have you tried the Recipients collection?

    for each Recip in mail.Recipients

      MsgBox Recip.Address

    next


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Thursday, December 1, 2011 2:58 PM
  • thanks for the codes. however it gets the recipients email. i need to get the sender's email.

    i tried    sender = Application.Session.CurrentUser.Address()

    however it gets the default user. but if i were to change the email sender to another user in the new e-mail, it does not get the sender but rather the default email address.

    please help thanks

    • Edited by noobie1 Friday, December 2, 2011 1:25 AM
    Friday, December 2, 2011 1:07 AM