Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / November 2004

Tip: Looking for answers? Try searching our database.

Unknown error on RTF formatted email after applying Redemption

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bingo - 23 Nov 2004 19:01 GMT
I need to forward emails to a specific email account but
still keep the original subject and message body.  

I use Redeption SafeMailItem to get the RTFbody from the
original mail item and pass it on to the new mail item
(OriginalMailItem.Forward).  Then I send out the mail
item.  On the other side, once I got the forwarded
emails, I run an VB app to on those mail items.  If the
mail is in RTF format with embedded OLE objects,

oMapiMailItem.ReplyAll and
oMapiMailItem.Forward both are working correctly.  

But if the mail has no message body or just plain text in
the body, the above two commands failed and VB generates
an Unknown error.  

I tried to send email from Redemption SafeMailItem and
Outlook MailItem after applying the RTFbody and both have
the same problem with RTF formatted emails--with either
no message body or plain text body.  

What's the work-around?  Thanks.
Dmitry Streblechenko \(MVP\) - 23 Nov 2004 20:49 GMT
Do you have a code snippet that exhibits this problem?

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

> I need to forward emails to a specific email account but
> still keep the original subject and message body.
[quoted text clipped - 19 lines]
>
> What's the work-around?  Thanks.
Bingo - 23 Nov 2004 20:57 GMT
I'll post the code shortly.  

Just found out that Outlook cannot print these emails
either.  Thanks.  

>-----Original Message-----
>Do you have a code snippet that exhibits this problem?
[quoted text clipped - 29 lines]
>
>.
Bingo - 23 Nov 2004 21:11 GMT
Dmitry,

The following are two portions of the code I have.  The
top one is used to send out an email using the RTFbody
off SafeMailItem.  The 2nd part is where the error
actually happens.

' The code to "forward" an email
' to a specified email account
   
   ' Get mail item by mail ID
   Set oMapiMail = oNsp.GetItemFromID(sMailID)
   
   ' Forward method will change mail
   ' subject and mail body
   Set oMapiMailNew = oMapiMail.Forward
   
   ' Get the same formatting
   With oMapiMailNew
       .Subject = oMapiMail.Subject
       If oMapiMail.HTMLBody = vbNullString Then
           bRdp = True     ' Use the RTF property of
                           ' the Redemption Safe Mail
                           ' Item
       Else
           bRdp = False    ' Use the HTML property of
                           ' the Outlook Object Mapi
                           ' Mail Item
           .HTMLBody = oMapiMail.HTMLBody
       End If
       .MessageClass = CustomMessageClass
       .Save               ' Save the cloned mail item
                           ' to avoid outlook object
                           ' overwriting redemption
       sMailID = oMapiMailNew.EntryID
   End With
   
   ' Re-cycle the object
   Set oMapiMailNew = Nothing
   Set oMapiMailNew = oNsp.GetItemFromID(sMailID)
   
   ' Add the mailbox as the only recipient
   Set oMapiRecipient = oMapiRecipients.Add("bingo")
   With oMapiRecipient
       .Type = 1       ' 1: olTo
   End With
   
   ' Populate the hidden fields
   With oMapiMailNew
       .UserProperties("abc") = "abc"
       
       ' To keep the RTF formatting of the
       ' original mail item
       If bRdp Then
           Set oRdpMail = CreateObject
("Redemption.SafeMailItem")
           Set oRdpMailNew = CreateObject
("Redemption.SafeMailItem")
           ' Original mail item
           oRdpMail.Item = oMapiMail      
           ' Clone mail item
           oRdpMailNew.Item = oMapiMailNew
           ' Get the original RTF formatting
           oRdpMailNew.RTFBody = oRdpMail.RTFBody  
'            oRdpMailNew.Send ' I tried this as well
       End If
       .Send
   End With

'--------------------

' After sending the email, the following code is
' used on the receiving side
' to operate on the email
' Reply, ReplyAll, Forward and Print operations
' in VB app will all fail
' an unknow error generates
' Print will fail even in Outlook but Reply,
' ReplyAll and Forward work fine
' in Outlook on the same email

   Set oMapiMailReply = oMapiMail.ReplyAll
   Set oMapiMailForward = oMapiMail.Forward
   
   

>-----Original Message-----
>Do you have a code snippet that exhibits this problem?
[quoted text clipped - 29 lines]
>
>.
Dmitry Streblechenko \(MVP\) - 25 Nov 2004 22:39 GMT
You will get errors in case of the embedded OLE objects since RTFBody refers
to the embedded objects which are attachments, but you do not copy
them.(andt here is no easy way to copy them)
Try to use SafeMailItem.CopyTo instead - it will copy all properties,
including the RTF body and attachments.

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

> Dmitry,
>
[quoted text clipped - 122 lines]
> >
> >.
Bingo - 26 Nov 2004 14:28 GMT
Dmitry,

I got what you say.  But the unknown error only happens
with RTF formatted emails without OLE objects.  In other
words, it works fine if there are OLE objects.  For RTF
emails with either plain text or no empty body, the
unknown error happens.  But I'm going to try the CopyTo
method as you recommended.  I'm pretty sure if you try
the code I provided, you'll see the error.  Thanks.  

>-----Original Message-----
>You will get errors in case of the embedded OLE objects since RTFBody refers
[quoted text clipped - 136 lines]
>
>.
Bingo - 26 Nov 2004 15:23 GMT
Dmitry,

I use Outlook Spy checked on these emails.  When I run
the Call of Forward function, I got Return Error Code
0xD0720009.  The Return Code for Reply function is
0xD6A20009, the code for ReplyAll is 0xDAC20009, the code
for PrintOut is 0xE0F20009.  All other functions are OK.  
Hope this helps.  

>-----Original Message-----
>You will get errors in case of the embedded OLE objects since RTFBody refers
[quoted text clipped - 136 lines]
>
>.
Dmitry Streblechenko \(MVP\) - 29 Nov 2004 18:03 GMT
Can you send to my private address the problematic messages saved as MSG
files (File|Save As), zipped (important!).

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

> Dmitry,
>
[quoted text clipped - 157 lines]
> >
> >.
Bingo - 30 Nov 2004 14:37 GMT
Dmitry,

After I rebuilt the custom form and cleared the form
cache, this problem went away.  Thanks!  

>-----Original Message-----
>Can you send to my private address the problematic messages saved as MSG
[quoted text clipped - 168 lines]
>
>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.