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

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
 
K

Ken Slovak - [MVP - Outlook]

So what happens if you comment out the line where you are changing the
HTMLBody property? That's what has all the html.
 
O

OneEDP

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
 
K

Ken Slovak - [MVP - Outlook]

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?
 
O

OneEDP

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
 
K

Ken Slovak - [MVP - Outlook]

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

OneEDP

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
 
K

Ken Slovak - [MVP - Outlook]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top