A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How do I modify the message body displayed in the email window?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 8th 06, 04:48 PM posted to microsoft.public.outlook.program_addins
Steffen Heinzl
external usenet poster
 
Posts: 14
Default 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  
Old November 8th 06, 07:17 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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  
Old November 9th 06, 05:53 PM posted to microsoft.public.outlook.program_addins
Steffen Heinzl
external usenet poster
 
Posts: 14
Default 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  
Old November 9th 06, 08:31 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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  
Old November 10th 06, 10:49 AM posted to microsoft.public.outlook.program_addins
Steffen Heinzl
external usenet poster
 
Posts: 14
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 04:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.