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

Write RTF-Body on ItemSend event



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 2nd 07, 01:51 PM posted to microsoft.public.outlook.program_addins
Thomas
external usenet poster
 
Posts: 2
Default Write RTF-Body on ItemSend event

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

  #2  
Old February 2nd 07, 08:35 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Write RTF-Body on ItemSend event

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" wrote in message
ups.com...
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



  #3  
Old February 12th 07, 11:22 AM posted to microsoft.public.outlook.program_addins
Thomas
external usenet poster
 
Posts: 2
Default Write RTF-Body on ItemSend event

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" wrote:
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" wrote in message

ups.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 -



 




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
ItemSend event differences betweek W2K & WXP Lionel H Outlook and VBA 4 October 20th 06 03:16 PM
Changing RTF Body on MailItem Read event [email protected] Add-ins for Outlook 3 September 13th 06 07:30 PM
How to write new calendar event from internet application? jhajko via OfficeKB.com Outlook - Calandaring 2 May 9th 06 03:56 PM
Inserting RTF Text in a Message Body Ridge Kennedy Outlook and VBA 4 April 12th 06 03:29 PM
Embed an image in rtf doc (appointment or email body) Sue Mosher [MVP-Outlook] Outlook and VBA 0 February 1st 06 04:20 PM


All times are GMT +1. The time now is 12:34 PM.


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