If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
How do I modify the message body displayed in the email window?
Hi!
I'm writing an Outlook add-in with VSTO in C#. Up to now, I used the shortcutBar example (from the MSDN) which creates a few buttons. By clicking on a button named New Mail, the normal window appears, in which the Outlook user can write his mail. Then I added an AttachmentAddEventHandler, which reacts whenever an Attachment is added to the mail. The function handling the event receives an Attachment object. By calling attachment.Parent, I get the email to which the attachment was added. Now I can modify the body of the mail. The modification works for the mail object, but is not reflected to the form where the body of the Email is shown. Does anybody know how to update the window or at least how to get a reference to it? Yours, Steffen |
Ads |
#2
|
|||
|
|||
How do I modify the message body displayed in the email window?
The window you can get a reference to from your item you get from
Attachment.Parent. It would be Item.GetInspector to get an Inspector object. You can also trap the NewInspector event of the Inspectors collection to get a reference to the Inspector. ActiveInspector is probably also useful, it's the active window so would most likely be the window you want. However, changes you make in code won't show up unless you save the item and even then may take a while due to latency. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Steffen Heinzl" wrote in message ... Hi! I'm writing an Outlook add-in with VSTO in C#. Up to now, I used the shortcutBar example (from the MSDN) which creates a few buttons. By clicking on a button named New Mail, the normal window appears, in which the Outlook user can write his mail. Then I added an AttachmentAddEventHandler, which reacts whenever an Attachment is added to the mail. The function handling the event receives an Attachment object. By calling attachment.Parent, I get the email to which the attachment was added. Now I can modify the body of the mail. The modification works for the mail object, but is not reflected to the form where the body of the Email is shown. Does anybody know how to update the window or at least how to get a reference to it? Yours, Steffen |
#3
|
|||
|
|||
How do I modify the message body displayed in the email window?
Ken Slovak - [MVP - Outlook] wrote:
The window you can get a reference to from your item you get from Attachment.Parent. It would be Item.GetInspector to get an Inspector object. You can also trap the NewInspector event of the Inspectors collection to get a reference to the Inspector. ActiveInspector is probably also useful, it's the active window so would most likely be the window you want. However, changes you make in code won't show up unless you save the item and even then may take a while due to latency. Thanks! By the method GetInspector, I can get an Inspector obect. But what can I do with the inspector object? I do not seem to find an attribute or function that can do something for me. If I may ask another (more important) question: I want to add a text for each attachment attached when the send button is clicked. But if I do something like... Outlook.MailItem newMail = (Outlook.MailItem)outlookApp.CreateItem(Outlook.Ol ItemType.olMailItem); Outlook.ItemEvents_10_Event temp = (Outlook.ItemEvents_10_Event)newMail; temp.Send += new Outlook.ItemEvents_10_SendEventHandler(MySendHandl er); temp.AttachmentAdd += new Outlook.ItemEvents_10_AttachmentAddEventHandler(My AttachmentHandler); .... MySendHandler is never called, when I click the send button or actually send the mail. But if I add an Attachment MyAttachmentHandler is called. Yours, Steffen |
#4
|
|||
|
|||
How do I modify the message body displayed in the email window?
You asked how to get the window for the item, the Inspector is the window
for the item. Inspector.CurrentItem is the item in the window, and getting that as a mail item gives you access to Body and other properties. If you already have the mail item you don't need the Inspector most likely. I'd guess for your other problem that the event handler is out of scope. Normally one would use some form of Inspector wrapper class to wrap each Inspector that's opened and in that class would live the event handlers for the Inspector and the item in it. The wrapper class is then kept alive by adding it to a collection or SortedList or something else that prevents the garbage collector from removing it. There's an Inspector wrapper in C# that you might want to look at, it's at http://www.outlookcode.com/codedetail.aspx?id=797 -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Steffen Heinzl" wrote in message ... Thanks! By the method GetInspector, I can get an Inspector obect. But what can I do with the inspector object? I do not seem to find an attribute or function that can do something for me. If I may ask another (more important) question: I want to add a text for each attachment attached when the send button is clicked. But if I do something like... Outlook.MailItem newMail = (Outlook.MailItem)outlookApp.CreateItem(Outlook.Ol ItemType.olMailItem); Outlook.ItemEvents_10_Event temp = (Outlook.ItemEvents_10_Event)newMail; temp.Send += new Outlook.ItemEvents_10_SendEventHandler(MySendHandl er); temp.AttachmentAdd += new Outlook.ItemEvents_10_AttachmentAddEventHandler(My AttachmentHandler); ... MySendHandler is never called, when I click the send button or actually send the mail. But if I add an Attachment MyAttachmentHandler is called. Yours, Steffen |
#5
|
|||
|
|||
How do I modify the message body displayed in the email window?
Ken Slovak - [MVP - Outlook] wrote:
You asked how to get the window for the item, the Inspector is the window for the item. Inspector.CurrentItem is the item in the window, and getting that as a mail item gives you access to Body and other properties. If you already have the mail item you don't need the Inspector most likely. I'd guess for your other problem that the event handler is out of scope. Normally one would use some form of Inspector wrapper class to wrap each Inspector that's opened and in that class would live the event handlers for the Inspector and the item in it. The wrapper class is then kept alive by adding it to a collection or SortedList or something else that prevents the garbage collector from removing it. There's an Inspector wrapper in C# that you might want to look at, it's at http://www.outlookcode.com/codedetail.aspx?id=797 Thank you very much! Now it works! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to foward just a specific part of an email body of message | [email protected] | Outlook and VBA | 6 | August 21st 06 09:07 PM |
Email font size in body changes randomly after the message is sent | [email protected] | Outlook - General Queries | 0 | May 31st 06 10:52 PM |
Help: Send To Email Message in Body | TJ | Outlook Express | 3 | May 4th 06 01:23 PM |
Modify Outlook Login window | Nphil | Outlook - Installation | 1 | April 8th 06 02:12 PM |
How to filter email with blank subject, to, and message body | ken4az | Outlook - Installation | 0 | January 20th 06 06:27 PM |