none
SendMail Event Handle in Microsoft Word 2007 RRS feed

  • Question

  • Hy,

    In my Application i have to Cancel the Event Word.SendMail(). Is it Possible to catch the Event? Ist there an Event like BeforeSendMail similar to Word.DocumentBeforSave or Word.DocumentBeforeClose?

    Thanks!

    Tuesday, May 17, 2011 8:08 AM

Answers

  • Hi,

     

    Why do you want to retrieve this event handler? The method just open message window and will not send the mail until you hit the send button. It’s unlike to capture the event in Word application, however, you can try to use Application.ItemLoad Event (Outlook) and MailItem.BeforeAttachmentAdd Event (Outlook)

     

    Something like:

          private void ThisAddIn_Startup(object sender, System.EventArgs e)

            {

                Application.ItemLoad += new Outlook.ApplicationEvents_11_ItemLoadEventHandler(app_ItemLoad);

            }

     

            void app_ItemLoad(object Item)

            {

                Outlook.MailItem item = Item as Outlook.MailItem;

                if (item != null)

                {

                    item.BeforeAttachmentAdd += new Outlook.ItemEvents_10_BeforeAttachmentAddEventHandler(item_BeforeAttachmentAdd);

                    //item.AttachmentAdd += new Outlook.ItemEvents_10_AttachmentAddEventHandler(item_AttachmentAdd);     

                } 

            }

            void item_BeforeAttachmentAdd(Outlook.Attachment Attachment, ref bool Cancel)

            {

                MessageBox.Show(Attachment.FileName);

            }

     

    I hope this helps.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 24, 2011 1:26 PM
    Moderator