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 » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , , , , ,

save Email as HTML file with embedded pictures after udpdate HTMLbody





 
 
Thread Tools Display Modes
  #1  
Old February 1st 07, 02:50 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Oliv'
external usenet poster
 
Posts: 6
Default save Email as HTML file with embedded pictures after udpdate HTMLbody

Hello,
I want to save Email as HTML file with embedded pictures.
First i update HTMLBODY to change cid: to attachment.filename

It's ok but i need the line
MsgBox "Save in progress"
else the html file is not update.

I don't know why ?

Thank you

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have a nice day
Oliv'
Outlook : http://faq.outlook.free.fr/
les archives : http://groups.google.com/group/micro...lic.fr.outlook
Dernière chance http://www.outlookcode.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Sub IsEmbedded()
Dim objCurrentMessage As Outlook.MailItem
Dim colAttach As Outlook.Attachments
Dim Sujet
Dim OLDhtml
Dim strEntryID
Set objCurrentMessage = ActiveInspector.CurrentItem
Set colAttach = objCurrentMessage.Attachments

Sujet = objCurrentMessage.ConversationIndex
Sujet =
Replace(Replace(Replace(Replace(Replace(Replace(Re place(Replace(Replace(Replace(Replace(objCurrentMe ssage.SenderEmailAddress
& objCurrentMessage.ReceivedTime & objCurrentMessage.ReceivedByName, "\",
""), "/", ""), ":", ""), "*", ""), "?", ""), "", ""), "", ""), "|", ""),
".", ""), """", ""), " - Gras Savoye Ricour", "")
If Sujet = "" Then Sujet = objCurrentMessage.EntryID
'on crée le repertoire où mettre les fichiers joints
################################################## ########
repertoire = "c:\temp\Email\" & Sujet & "\"
If "" = Dir("c:\temp\Email\", vbDirectory) Then
MkDir "c:\temp\Email\"
End If

If repertoire "" Then
If "" = Dir(repertoire, vbDirectory) Then
MkDir repertoire
End If
If "" = Dir(repertoire & "embedded\", vbDirectory) Then
MkDir repertoire & "embedded\"
End If
End If
'================================================= ================
'On boucle sur les pj pour enlever le cid et enregistrer la pj
'================================================= ================
OLDhtml = objCurrentMessage.HTMLBody

strEntryID = objCurrentMessage.EntryID
Dim i, toto
For i = 1 To colAttach.Count
toto = Attachtype(strEntryID, colAttach(i).index)
'MsgBox "type:=" & toto & vbCr & " Piece:= " & colAttach(i).FileName
objCurrentMessage.HTMLBody = Replace(objCurrentMessage.HTMLBody, "cid:"
& toto, "embedded\" & colAttach(i).FileName)
colAttach(i).SaveAsFile repertoire & "embedded\" & colAttach(i).FileName
Next i

'================================================= ================
'on enregistre le mail
'================================================= ================
objCurrentMessage.Save
objCurrentMessage.Display
'Sleep 5000
MsgBox "Save in progress"
strname = repertoire & "Email " &
Left(Replace(Replace(Replace(Replace(Replace(Repla ce(Replace(Replace(Replace(Replace(Replace(Replace (Sujet,
"\", ""), "/", ""), ":", ""), "*", ""), "?", ""), "", ""), "", ""), "|",
""), ".", ""), """", ""), vbTab, ""), Chr(7), ""), 160)
objCurrentMessage.SaveAs strname & ".htm", OlSaveAsType.olHTML
objCurrentMessage.HTMLBody = OLDhtml
objCurrentMessage.Save

Dim ExpShell As Object
Dim cmdshell, cmdshell1, resultat
Set ExpShell = CreateObject("WScript.Shell")

cmdshell = "explorer " & repertoire
cmdshell1 = "explorer " & strname & ".htm"
resultat = ExpShell.Run(cmdshell, 1, False)
resultat = ExpShell.Run(cmdshell1, 1, False)
'Shell cmdshell, vbMaximizedFocus

'cmdshell = "explorer " & repertoire
'Shell cmdshell, vbMaximizedFocus
'================================================= ================
'Fin on nettoie
'================================================= ================
On Error Resume Next
'Kill (repertoire & "*.*")
'RmDir (repertoire)
repertoire = ""
Sujet = ""
strEntryID = ""
Set objCurrentMessage = Nothing
Set colAttach = Nothing
Set ExpShell = Nothing
'Attente.Repaint
'Unload Attente
End Sub

' Function: Fields_Selector
' Purpose: View type of attachment
' olivier catteau fevrier 2006
Function Attachtype(ByVal strEntryID As String, attindex As Integer) As
Variant

Dim oSession As MAPI.Session
' CDO objects
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment

' initialize CDO session
On Error Resume Next
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False

' get the message created earlier
Set oMsg = oSession.GetMessage(strEntryID)
' set properties of the attached graphic that make
' it embedded and give it an ID for use in an IMG tag
Set oAttachs = oMsg.Attachments
Set oAttach = oAttachs.Item(attindex)
Dim strCID As String
strCID = oAttach.Fields(&H3712001E)

Attachtype = strCID
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
End Function



Ads
  #2  
Old February 1st 07, 03:59 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,779
Default save Email as HTML file with embedded pictures after udpdate HTMLbody

Please clarify. Are you saving the Outlook item after you update the
HTMLBody? Are you calling SaveAs to update the saved MSG file?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Oliv'" wrote in message
...
Hello,
I want to save Email as HTML file with embedded pictures.
First i update HTMLBODY to change cid: to attachment.filename

It's ok but i need the line
MsgBox "Save in progress"
else the html file is not update.

I don't know why ?

Thank you

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have a nice day
Oliv'
Outlook : http://faq.outlook.free.fr/
les archives : http://groups.google.com/group/micro...lic.fr.outlook
Dernière chance http://www.outlookcode.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Sub IsEmbedded()
Dim objCurrentMessage As Outlook.MailItem
Dim colAttach As Outlook.Attachments
Dim Sujet
Dim OLDhtml
Dim strEntryID
Set objCurrentMessage = ActiveInspector.CurrentItem
Set colAttach = objCurrentMessage.Attachments

Sujet = objCurrentMessage.ConversationIndex
Sujet =
Replace(Replace(Replace(Replace(Replace(Replace(Re place(Replace(Replace(Replace(Replace(objCurrentMe ssage.SenderEmailAddress
& objCurrentMessage.ReceivedTime & objCurrentMessage.ReceivedByName, "\",
""), "/", ""), ":", ""), "*", ""), "?", ""), "", ""), "", ""), "|", ""),
".", ""), """", ""), " - Gras Savoye Ricour", "")
If Sujet = "" Then Sujet = objCurrentMessage.EntryID
'on crée le repertoire où mettre les fichiers joints
################################################## ########
repertoire = "c:\temp\Email\" & Sujet & "\"
If "" = Dir("c:\temp\Email\", vbDirectory) Then
MkDir "c:\temp\Email\"
End If

If repertoire "" Then
If "" = Dir(repertoire, vbDirectory) Then
MkDir repertoire
End If
If "" = Dir(repertoire & "embedded\", vbDirectory) Then
MkDir repertoire & "embedded\"
End If
End If
'================================================= ================
'On boucle sur les pj pour enlever le cid et enregistrer la pj
'================================================= ================
OLDhtml = objCurrentMessage.HTMLBody

strEntryID = objCurrentMessage.EntryID
Dim i, toto
For i = 1 To colAttach.Count
toto = Attachtype(strEntryID, colAttach(i).index)
'MsgBox "type:=" & toto & vbCr & " Piece:= " & colAttach(i).FileName
objCurrentMessage.HTMLBody = Replace(objCurrentMessage.HTMLBody, "cid:"
& toto, "embedded\" & colAttach(i).FileName)
colAttach(i).SaveAsFile repertoire & "embedded\" &
colAttach(i).FileName
Next i

'================================================= ================
'on enregistre le mail
'================================================= ================
objCurrentMessage.Save
objCurrentMessage.Display
'Sleep 5000
MsgBox "Save in progress"
strname = repertoire & "Email " &
Left(Replace(Replace(Replace(Replace(Replace(Repla ce(Replace(Replace(Replace(Replace(Replace(Replace (Sujet,
"\", ""), "/", ""), ":", ""), "*", ""), "?", ""), "", ""), "", ""), "|",
""), ".", ""), """", ""), vbTab, ""), Chr(7), ""), 160)
objCurrentMessage.SaveAs strname & ".htm", OlSaveAsType.olHTML
objCurrentMessage.HTMLBody = OLDhtml
objCurrentMessage.Save

Dim ExpShell As Object
Dim cmdshell, cmdshell1, resultat
Set ExpShell = CreateObject("WScript.Shell")

cmdshell = "explorer " & repertoire
cmdshell1 = "explorer " & strname & ".htm"
resultat = ExpShell.Run(cmdshell, 1, False)
resultat = ExpShell.Run(cmdshell1, 1, False)
'Shell cmdshell, vbMaximizedFocus

'cmdshell = "explorer " & repertoire
'Shell cmdshell, vbMaximizedFocus
'================================================= ================
'Fin on nettoie
'================================================= ================
On Error Resume Next
'Kill (repertoire & "*.*")
'RmDir (repertoire)
repertoire = ""
Sujet = ""
strEntryID = ""
Set objCurrentMessage = Nothing
Set colAttach = Nothing
Set ExpShell = Nothing
'Attente.Repaint
'Unload Attente
End Sub

' Function: Fields_Selector
' Purpose: View type of attachment
' olivier catteau fevrier 2006
Function Attachtype(ByVal strEntryID As String, attindex As Integer) As
Variant

Dim oSession As MAPI.Session
' CDO objects
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment

' initialize CDO session
On Error Resume Next
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False

' get the message created earlier
Set oMsg = oSession.GetMessage(strEntryID)
' set properties of the attached graphic that make
' it embedded and give it an ID for use in an IMG tag
Set oAttachs = oMsg.Attachments
Set oAttach = oAttachs.Item(attindex)
Dim strCID As String
strCID = oAttach.Fields(&H3712001E)

Attachtype = strCID
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
End Function




  #3  
Old February 1st 07, 06:15 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Oliv'
external usenet poster
 
Posts: 6
Default save Email as HTML file with embedded pictures after udpdate HTMLbody


*Ken Slovak - [MVP - Outlook] que je salue a écrit *:
Please clarify. Are you saving the Outlook item after you update the
HTMLBody?

yes i update objCurrentMessage.HTMLBody (see "*1" below
i save objCurrentMessage.save (see "*2")

Are you calling SaveAs to update the saved MSG file?


yes objCurrentMessage.saveas (see "*3" below)



"Oliv'" wrote in message
...
Hello,
I want to save Email as HTML file with embedded pictures.
First i update HTMLBODY to change cid: to attachment.filename

It's ok but i need the line
MsgBox "Save in progress"
else the html file is not update.

I don't know why ?

Thank you

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have a nice day
Oliv'
Outlook : http://faq.outlook.free.fr/
les archives :
http://groups.google.com/group/micro...lic.fr.outlook Dernière
chance http://www.outlookcode.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sub IsEmbedded()
Dim objCurrentMessage As Outlook.MailItem
Dim colAttach As Outlook.Attachments
Dim Sujet
Dim OLDhtml
Dim strEntryID
Set objCurrentMessage = ActiveInspector.CurrentItem
Set colAttach = objCurrentMessage.Attachments

Sujet = objCurrentMessage.ConversationIndex
Sujet =
Replace(Replace(Replace(Replace(Replace(Replace(Re place(Replace(Replace(Replace(Replace(objCurrentMe ssage.SenderEmailAddress
& objCurrentMessage.ReceivedTime & objCurrentMessage.ReceivedByName,
"\", ""), "/", ""), ":", ""), "*", ""), "?", ""), "", ""), "",
""), "|", ""), ".", ""), """", ""), " - Gras Savoye Ricour", "")
If Sujet = "" Then Sujet = objCurrentMessage.EntryID
'on crée le repertoire où mettre les fichiers joints
################################################## ########
repertoire = "c:\temp\Email\" & Sujet & "\"
If "" = Dir("c:\temp\Email\", vbDirectory) Then
MkDir "c:\temp\Email\"
End If

If repertoire "" Then
If "" = Dir(repertoire, vbDirectory) Then
MkDir repertoire
End If
If "" = Dir(repertoire & "embedded\", vbDirectory) Then
MkDir repertoire & "embedded\"
End If
End If
'================================================= ================
'On boucle sur les pj pour enlever le cid et enregistrer la pj
'================================================= ================
OLDhtml = objCurrentMessage.HTMLBody

strEntryID = objCurrentMessage.EntryID
Dim i, toto
For i = 1 To colAttach.Count
toto = Attachtype(strEntryID, colAttach(i).index)
'MsgBox "type:=" & toto & vbCr & " Piece:= " &
colAttach(i).FileName

*1 objCurrentMessage.HTMLBody =
Replace(objCurrentMessage.HTMLBody, "cid:" & toto, "embedded\" &
colAttach(i).FileName) colAttach(i).SaveAsFile repertoire &
"embedded\" & colAttach(i).FileName
Next i

'================================================= ================
'on enregistre le mail
'================================================= ================

*2 objCurrentMessage.Save
objCurrentMessage.Display
'Sleep 5000
MsgBox "Save in progress"
strname = repertoire & "Email " &
Left(Replace(Replace(Replace(Replace(Replace(Repla ce(Replace(Replace(Replace(Replace(Replace(Replace (Sujet,
"\", ""), "/", ""), ":", ""), "*", ""), "?", ""), "", ""), "",
""), "|", ""), ".", ""), """", ""), vbTab, ""), Chr(7), ""), 160)

*3 objCurrentMessage.SaveAs strname & ".htm", OlSaveAsType.olHTML
objCurrentMessage.HTMLBody = OLDhtml
objCurrentMessage.Save

Dim ExpShell As Object
Dim cmdshell, cmdshell1, resultat
Set ExpShell = CreateObject("WScript.Shell")

cmdshell = "explorer " & repertoire
cmdshell1 = "explorer " & strname & ".htm"
resultat = ExpShell.Run(cmdshell, 1, False)
resultat = ExpShell.Run(cmdshell1, 1, False)
'Shell cmdshell, vbMaximizedFocus

'cmdshell = "explorer " & repertoire
'Shell cmdshell, vbMaximizedFocus
'================================================= ================
'Fin on nettoie
'================================================= ================
On Error Resume Next
'Kill (repertoire & "*.*")
'RmDir (repertoire)
repertoire = ""
Sujet = ""
strEntryID = ""
Set objCurrentMessage = Nothing
Set colAttach = Nothing
Set ExpShell = Nothing
'Attente.Repaint
'Unload Attente
End Sub

' Function: Fields_Selector
' Purpose: View type of attachment
' olivier catteau fevrier 2006
Function Attachtype(ByVal strEntryID As String, attindex As Integer)
As Variant

Dim oSession As MAPI.Session
' CDO objects
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment

' initialize CDO session
On Error Resume Next
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False

' get the message created earlier
Set oMsg = oSession.GetMessage(strEntryID)
' set properties of the attached graphic that make
' it embedded and give it an ID for use in an IMG tag
Set oAttachs = oMsg.Attachments
Set oAttach = oAttachs.Item(attindex)
Dim strCID As String
strCID = oAttach.Fields(&H3712001E)

Attachtype = strCID
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
End Function



  #4  
Old February 1st 07, 09:25 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,779
Default save Email as HTML file with embedded pictures after udpdate HTMLbody

And is the MSG file and the original item both updated? I don't understand
the problem or why you would need a MsgBox dialog.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Oliv'" wrote in message
...

*Ken Slovak - [MVP - Outlook] que je salue a écrit *:
Please clarify. Are you saving the Outlook item after you update the
HTMLBody?

yes i update objCurrentMessage.HTMLBody (see "*1" below
i save objCurrentMessage.save (see "*2")

Are you calling SaveAs to update the saved MSG file?


yes objCurrentMessage.saveas (see "*3" below)


  #5  
Old February 2nd 07, 12:14 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Oliv'
external usenet poster
 
Posts: 6
Default save Email as HTML file with embedded pictures after udpdate HTMLbody


*Ken Slovak - [MVP - Outlook] que je salue a écrit *:
And is the MSG file and the original item both updated? I don't
understand the problem or why you would need a MsgBox dialog.


Precisely, I don't want this MsgBox dialog but if it is not there export is
not good.
link to my code as .bas file http://cjoint.com/?ccmnqyrzFU if you want to
test it
you need "c:\temp" directory
Sorry my english is very bad
Oliv'


  #6  
Old February 2nd 07, 04:09 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,779
Default save Email as HTML file with embedded pictures after udpdate HTMLbody

No, I don't download and run code from the Web, sorry.

Show the relevant piece of your code in a post here and let us see what you
are doing and also provide the message the dialog is showing so we know
what's going on.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Oliv'" wrote in message
...

*Ken Slovak - [MVP - Outlook] que je salue a écrit *:
And is the MSG file and the original item both updated? I don't
understand the problem or why you would need a MsgBox dialog.


Precisely, I don't want this MsgBox dialog but if it is not there export
is not good.
link to my code as .bas file http://cjoint.com/?ccmnqyrzFU if you want to
test it
you need "c:\temp" directory
Sorry my english is very bad
Oliv'



  #7  
Old February 2nd 07, 05:07 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Oliv'
external usenet poster
 
Posts: 6
Default save Email as HTML file with embedded pictures after udpdate HTMLbody


*Ken Slovak - [MVP - Outlook] que je salue a écrit *:
No, I don't download and run code from the Web, sorry.

Show the relevant piece of your code in a post here and let us see
what you are doing and also provide the message the dialog is showing
so we know what's going on.


Hello Ken
If i comment MsgBox "IN PROGRESS" the export is bad why ?
Thank you
This is my code :

Sub SaveAsHtmlFileWithEmbedded()
Dim objCurrentMessage As Outlook.MailItem
Dim colAttach As Outlook.Attachments
Dim Sujet
Dim OLDhtml
Dim strEntryID
Set objCurrentMessage = ActiveInspector.CurrentItem
Set colAttach = objCurrentMessage.Attachments
If objCurrentMessage.BodyFormat = olFormatHTML Then
Sujet = objCurrentMessage.ConversationIndex
Sujet = "mail"
'on crée le repertoire où mettre les fichiers joints
repertoire = "c:\temp\Email\" & Sujet & "\"

OLDhtml = objCurrentMessage.HTMLBody

strEntryID = objCurrentMessage.EntryID
Dim i, toto
For i = 1 To colAttach.Count
toto = Attachtype(strEntryID, colAttach(i).Index)
objCurrentMessage.HTMLBody = Replace(objCurrentMessage.HTMLBody, _
"cid:" & toto, "embedded\" & colAttach(i).FileName)
colAttach(i).SaveAsFile repertoire & "embedded\" & _
colAttach(i).FileName
Next i


objCurrentMessage.Save
'================================================= ======================
MsgBox "IN PROGRESS"
'================================================= ======================
strname = repertoire & "Email " & Sujet
objCurrentMessage.SaveAs strname & ".htm", OlSaveAsType.olHTML
objCurrentMessage.HTMLBody = OLDhtml
objCurrentMessage.Save

On Error Resume Next
repertoire = ""
Sujet = ""
strEntryID = ""
End If
Set objCurrentMessage = Nothing
Set colAttach = Nothing
Set ExpShell = Nothing
End Sub

Function Attachtype(ByVal strEntryID As String, attindex As Integer) _
As Variant
Dim oSession As MAPI.Session
' CDO objects
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment
On Error Resume Next
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Set oMsg = oSession.GetMessage(strEntryID)
Set oAttachs = oMsg.Attachments
Set oAttach = oAttachs.Item(attindex)
Dim strCID As String
strCID = oAttach.Fields(&H3712001E)
Attachtype = strCID
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
End Function


"Oliv'" wrote in message
...

*Ken Slovak - [MVP - Outlook] que je salue a
écrit *:
And is the MSG file and the original item both updated? I don't
understand the problem or why you would need a MsgBox dialog.


Precisely, I don't want this MsgBox dialog but if it is not there
export is not good.
link to my code as .bas file http://cjoint.com/?ccmnqyrzFU if you
want to test it
you need "c:\temp" directory
Sorry my english is very bad
Oliv'



  #8  
Old February 2nd 07, 08:01 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,779
Default save Email as HTML file with embedded pictures after udpdate HTMLbody

First of all, I'd make the MAPI.Session object global or pass it to the CDO
procedure instead of logging on and logging off each time. That can cause
memory leaks. I'd also save the CDO.Message object after changing the
attachment fields.

Second, I'd release all references to the mail item before calling the CDO
code and then pick them up again after it returns.

Based on that code you are getting the original subject as Sujet and then
setting Sujet as "mail". Did you intend to concatenate "mail" to the current
ConversationIndex?

If I were doing this code I'd probably try to rewrite it to do only 1 call
to the CDO procedure if possible.

Instead of the MsgBox see if putting in a DoEvents helps in addition to my
other suggestions.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Oliv'" wrote in message
...

*Ken Slovak - [MVP - Outlook] que je salue a écrit *:
No, I don't download and run code from the Web, sorry.

Show the relevant piece of your code in a post here and let us see
what you are doing and also provide the message the dialog is showing
so we know what's going on.


Hello Ken
If i comment MsgBox "IN PROGRESS" the export is bad why ?
Thank you
This is my code :

Sub SaveAsHtmlFileWithEmbedded()
Dim objCurrentMessage As Outlook.MailItem
Dim colAttach As Outlook.Attachments
Dim Sujet
Dim OLDhtml
Dim strEntryID
Set objCurrentMessage = ActiveInspector.CurrentItem
Set colAttach = objCurrentMessage.Attachments
If objCurrentMessage.BodyFormat = olFormatHTML Then
Sujet = objCurrentMessage.ConversationIndex
Sujet = "mail"
'on crée le repertoire où mettre les fichiers joints
repertoire = "c:\temp\Email\" & Sujet & "\"

OLDhtml = objCurrentMessage.HTMLBody

strEntryID = objCurrentMessage.EntryID
Dim i, toto
For i = 1 To colAttach.Count
toto = Attachtype(strEntryID, colAttach(i).Index)
objCurrentMessage.HTMLBody = Replace(objCurrentMessage.HTMLBody, _
"cid:" & toto, "embedded\" & colAttach(i).FileName)
colAttach(i).SaveAsFile repertoire & "embedded\" & _
colAttach(i).FileName
Next i


objCurrentMessage.Save
'================================================= ======================
MsgBox "IN PROGRESS"
'================================================= ======================
strname = repertoire & "Email " & Sujet
objCurrentMessage.SaveAs strname & ".htm", OlSaveAsType.olHTML
objCurrentMessage.HTMLBody = OLDhtml
objCurrentMessage.Save

On Error Resume Next
repertoire = ""
Sujet = ""
strEntryID = ""
End If
Set objCurrentMessage = Nothing
Set colAttach = Nothing
Set ExpShell = Nothing
End Sub

Function Attachtype(ByVal strEntryID As String, attindex As Integer) _
As Variant
Dim oSession As MAPI.Session
' CDO objects
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment
On Error Resume Next
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Set oMsg = oSession.GetMessage(strEntryID)
Set oAttachs = oMsg.Attachments
Set oAttach = oAttachs.Item(attindex)
Dim strCID As String
strCID = oAttach.Fields(&H3712001E)
Attachtype = strCID
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
End Function


"Oliv'" wrote in message
...

*Ken Slovak - [MVP - Outlook] que je salue a
écrit *:
And is the MSG file and the original item both updated? I don't
understand the problem or why you would need a MsgBox dialog.


Precisely, I don't want this MsgBox dialog but if it is not there
export is not good.
link to my code as .bas file http://cjoint.com/?ccmnqyrzFU if you
want to test it
you need "c:\temp" directory
Sorry my english is very bad
Oliv'




  #9  
Old February 5th 07, 11:33 AM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Oliv'
external usenet poster
 
Posts: 6
Default save Email as HTML file with embedded pictures after udpdate HTMLbody


*Ken Slovak - [MVP - Outlook] *:
First of all, I'd make the MAPI.Session object global or pass it to
the CDO procedure instead of logging on and logging off each time.
That can cause memory leaks. I'd also save the CDO.Message object
after changing the attachment fields.

Second, I'd release all references to the mail item before calling
the CDO code and then pick them up again after it returns.

Based on that code you are getting the original subject as Sujet and
then setting Sujet as "mail". Did you intend to concatenate "mail" to
the current ConversationIndex?


If I were doing this code I'd probably try to rewrite it to do only 1
call to the CDO procedure if possible.

Instead of the MsgBox see if putting in a DoEvents helps in addition
to my other suggestions.


Hello Ken,
Yes i concatenate several fields
It's ok with DoEvents, and i will try to Improve my code with your
suggestions
Thank you .

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have a nice day
Oliv'
Outlook : http://faq.outlook.free.fr/
les archives : http://groups.google.com/group/micro...lic.fr.outlook
Dernière chance http://www.outlookcode.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




"Oliv'" wrote in message
...

*Ken Slovak - [MVP - Outlook] que je salue a
écrit *:
No, I don't download and run code from the Web, sorry.

Show the relevant piece of your code in a post here and let us see
what you are doing and also provide the message the dialog is
showing so we know what's going on.


Hello Ken
If i comment MsgBox "IN PROGRESS" the export is bad why ?
Thank you
This is my code :

Sub SaveAsHtmlFileWithEmbedded()
Dim objCurrentMessage As Outlook.MailItem
Dim colAttach As Outlook.Attachments
Dim Sujet
Dim OLDhtml
Dim strEntryID
Set objCurrentMessage = ActiveInspector.CurrentItem
Set colAttach = objCurrentMessage.Attachments
If objCurrentMessage.BodyFormat = olFormatHTML Then
Sujet = objCurrentMessage.ConversationIndex
Sujet = "mail"
'on crée le repertoire où mettre les fichiers joints
repertoire = "c:\temp\Email\" & Sujet & "\"

OLDhtml = objCurrentMessage.HTMLBody

strEntryID = objCurrentMessage.EntryID
Dim i, toto
For i = 1 To colAttach.Count
toto = Attachtype(strEntryID, colAttach(i).Index)
objCurrentMessage.HTMLBody = Replace(objCurrentMessage.HTMLBody, _
"cid:" & toto, "embedded\" & colAttach(i).FileName)
colAttach(i).SaveAsFile repertoire & "embedded\" & _
colAttach(i).FileName
Next i


objCurrentMessage.Save
'================================================= ======================
MsgBox "IN PROGRESS"
'================================================= ======================
strname = repertoire & "Email " & Sujet
objCurrentMessage.SaveAs strname & ".htm", OlSaveAsType.olHTML
objCurrentMessage.HTMLBody = OLDhtml
objCurrentMessage.Save

On Error Resume Next
repertoire = ""
Sujet = ""
strEntryID = ""
End If
Set objCurrentMessage = Nothing
Set colAttach = Nothing
Set ExpShell = Nothing
End Sub

Function Attachtype(ByVal strEntryID As String, attindex As Integer)
_ As Variant
Dim oSession As MAPI.Session
' CDO objects
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment
On Error Resume Next
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Set oMsg = oSession.GetMessage(strEntryID)
Set oAttachs = oMsg.Attachments
Set oAttach = oAttachs.Item(attindex)
Dim strCID As String
strCID = oAttach.Fields(&H3712001E)
Attachtype = strCID
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
End Function


"Oliv'" wrote in message
...

*Ken Slovak - [MVP - Outlook] que je salue a
écrit *:
And is the MSG file and the original item both updated? I don't
understand the problem or why you would need a MsgBox dialog.


Precisely, I don't want this MsgBox dialog but if it is not there
export is not good.
link to my code as .bas file http://cjoint.com/?ccmnqyrzFU if you
want to test it
you need "c:\temp" directory
Sorry my english is very bad
Oliv'



 




Thread Tools
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
IE7 - Can't save HTML pictures Res ipsa loquitor Outlook Express 3 December 12th 06 03:31 AM
Eingebundene Bilder in Outlook-HTML-Mail / embedded graphics in HTML Stefan Wirrer Outlook and VBA 0 August 23rd 06 02:26 PM
FYI: Eingebundene Bilder in Outlook-HTML-Mail / embedded graphics in HTML Stefan Wirrer Outlook - General Queries 1 August 17th 06 03:25 PM
FYI: Eingebundene Bilder in Outlook-HTML-Mail / embedded graphics in HTML Stefan Wirrer Outlook and VBA 1 August 17th 06 03:25 PM
Embedded Images - Cannot Save - The System cannot find the file sp mesoshauney Outlook Express 1 June 4th 06 03:41 AM


All times are GMT +1. The time now is 05:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Moissanite Jewelry For Sale - Credit Cards - Debt Consolidation Loans - Salvage cars - The eBay Song