Duplicate and edit a mailitem in OL2002 withouth lost html body and "glitters"

  • Thread starter Thread starter OneEDP
  • Start date Start date
O

OneEDP

In OL2000 I duplicate in VBA a mailitem as follow (both Win 98,ME,XP all SP,
office all SP):

Dim olApplication As Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olMailItem As Variant '!!!!
Dim olCopiedMailItem As Outlook.MailItem

Set olApplication = GetObject(, "Outlook.Application")
on error go to.....
Set olNameSpace = olApplication.GetNamespace("MAPI")
Set olMailItem =
olNameSpace.Folders(1).Folders("MyMimicTemplates").Items("MyIndex").Copy
olMailItem.Move olNameSpace.GetDefaultFolder(olFolderOutbox)
olMilItem.HTMLBody = ........ 'editing
olMailItem.Display
'delete dirty e-mail
Set olCopiedMailItem =
olNameSpace.GetDefaultFolder(olFolderOutbox).Items("MyIndex")
olCopiedMailItem.Delete
....

BUT... in Ol2002 any "glitters" (html, sign, images, etc.) were lost!
Please, help me.
Daniele
 
So what happens if you comment out the line where you are changing the
HTMLBody property? That's what has all the html.
 
Ken Slovak - said:
So what happens if you comment out the line where you are changing the
HTMLBody property? That's what has all the html.

All formatted chars were lost. There are only chars preformatted not in bold
or italic and any images.
Solution?
Thanks
Daniele
 
I'm not sure. A copy of an item should retain all the original properties of
the original item. If it was an HTML item with various formatting that
should be retained unless something or some code is modifying the item. Does
it look the same if you make the copy and then just display it?
 
Ken Slovak - said:
I'm not sure. A copy of an item should retain all the original properties
of the original item. If it was an HTML item with various formatting that
should be retained unless something or some code is modifying the item.
Does it look the same if you make the copy and then just display it?

Yes. After
Set olMailItem =
olNameSpace.Folders(1).Folders("MyMimicTemplates").Items("MyIndex").Copy
olMailItem.Display

The olMailItem destroy any format even if it keeps html property!
In Ol2000 there aren't failure, but in ol2002 there are... trouble.
Daniele
 
I can't repro this here.

I opened a formatted HTML email in an Outlook 2002 setup and used the
following VBA code:

Sub test()
Dim oMail As Outlook.MailItem
Dim oCopy As Outlook.MailItem

Set oMail = Application.ActiveInspector.CurrentItem

Set oCopy = oMail.Copy
oCopy.Display
End Sub

The formatting for oMail and oCopy were identical, nothing was lost at all.
I tried this both with and without WordMail being used to read/open/view the
emails.
 
In MyMimicTemplates there are old mailitem generated in ol2000.
After edit and save same mailitem (withouth change) by interface user (not
by vba), the same mailitem resume old behavior and "nothing was lost at
all!!"
Thank you very much.
We have fix a bit problem.
Thanks
Daniele
 
If you look at the raw HTML you'll see that the HTML generated by the
Outlook editor is very different than the HTML generated by the WordMail
editor. Also, each version of WordMail generates somewhat different HTML.
Both editors will also rewrite your HTML and change various tags, that drove
me nuts when I was injecting HTML into HTMLBody and had to case all the
different variations.

I'm glad you got it working.
 
Back
Top