Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Write RTF-Body on ItemSend event

Geek News

Write RTF-Body on ItemSend event
"Thomas" <office[ at ]ingbus.de> 2/2/2007 1:51:49 PM
I want to create a small Outlook addin that writes some additional
lines of RTF text to the body when the mail item is sent.

Writing RTF text into the body I'm using a small extended MAPI based
procedure written in VC++.

Everytime the code leaves the event handler I got the error:
"The messaging interface returned an unknown error. If the problem
persits, restart Outlook."

When opening the message again I can see the newly created RTF text.

My code looks like that:

Private WithEvents host As Outlook.application

Private Sub host_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim id As String
id = Item.entryID

Call AddMessageByEntryId(id, host, "Confidential message")

....
....
....


I found within the newsgroups answers that I have to dereference all
Outlook MailItem instances and create a new one by calling
GetItemFromID. But how can I do this when I'm in the event handler
that holds an instance itself?
Does anybody have an idea what could I do?
Any help greatly appreciated!


With best regards,

Thomas

Re: Write RTF-Body on ItemSend event
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 2/2/2007 8:35:15 PM
You get a conflict - looking at the AddMessageByEntryId() method, you pass
the entry id of the message (which will be "" if the message hasn't been
saved yet), most likely you MAPI code than reopens the message using
IMAPISession::OpenEntry. Instead of reopening the message, modify the MAPI
function to take an IUnknown and QI it for IMessage. On the VB side, pass
Item.MAPIOBJECT .

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Thomas" <office[ at ]ingbus.de> wrote in message
news:1170424309.875482.260730[ at ]q2g2000cwa.googlegroups.com...
[Quoted Text]
>I want to create a small Outlook addin that writes some additional
> lines of RTF text to the body when the mail item is sent.
>
> Writing RTF text into the body I'm using a small extended MAPI based
> procedure written in VC++.
>
> Everytime the code leaves the event handler I got the error:
> "The messaging interface returned an unknown error. If the problem
> persits, restart Outlook."
>
> When opening the message again I can see the newly created RTF text.
>
> My code looks like that:
>
> Private WithEvents host As Outlook.application
>
> Private Sub host_ItemSend(ByVal Item As Object, Cancel As Boolean)
> Dim id As String
> id = Item.entryID
>
> Call AddMessageByEntryId(id, host, "Confidential message")
>
> ....
> ....
> ....
>
>
> I found within the newsgroups answers that I have to dereference all
> Outlook MailItem instances and create a new one by calling
> GetItemFromID. But how can I do this when I'm in the event handler
> that holds an instance itself?
> Does anybody have an idea what could I do?
> Any help greatly appreciated!
>
>
> With best regards,
>
> Thomas
>


Re: Write RTF-Body on ItemSend event
"Thomas" <office[ at ]ingbus.de> 2/12/2007 11:22:14 AM
Thank you Dmitry once again!
I tried your solution and it is working grreat!

With best regards,

Thomas

On 2 Feb., 21:35, "Dmitry Streblechenko" <dmi...[ at ]dimastr.com> wrote:
[Quoted Text]
> You get a conflict - looking at the AddMessageByEntryId() method, you pass
> the entry id of the message (which will be "" if the message hasn't been
> saved yet), most likely you MAPI code than reopens the message using
> IMAPISession::OpenEntry. Instead of reopening the message, modify the MAPI
> function to take an IUnknown and QI it for IMessage. On the VB side, pass
> Item.MAPIOBJECT .
>
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Thomas" <off...[ at ]ingbus.de> wrote in message
>
> news:1170424309.875482.260730[ at ]q2g2000cwa.googlegroups.com...
>
>
>
> >I want to create a small Outlook addin that writes some additional
> > lines ofRTFtext to the body when the mail item is sent.
>
> > WritingRTFtext into the body I'm using a small extended MAPI based
> > procedure written in VC++.
>
> > Everytime the code leaves the event handler I got the error:
> > "The messaging interface returned an unknown error. If the problem
> > persits, restart Outlook."
>
> > When opening the message again I can see the newly createdRTFtext.
>
> > My code looks like that:
>
> > Private WithEvents host As Outlook.application
>
> > Private Sub host_ItemSend(ByVal Item As Object, Cancel As Boolean)
> > Dim id As String
> > id = Item.entryID
>
> > Call AddMessageByEntryId(id, host, "Confidential message")
>
> > ....
> > ....
> > ....
>
> > I found within the newsgroups answers that I have to dereference all
> > Outlook MailItem instances and create a new one by calling
> > GetItemFromID. But how can I do this when I'm in the event handler
> > that holds an instance itself?
> > Does anybody have an idea what could I do?
> > Any help greatly appreciated!
>
> > With best regards,
>
> > Thomas- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net