K
Karsten Pries
Hi,
the task is to create a new mail from a template (*.oft) with the user's
signature already in place at the end of the mail. Harder then it seems.
Aggravating factors:
- the template is HTML with embedded images (actually copied from Word)
- the user's signature is HTML and usually contains an embedded image
- every user has it's own signature
Version is Outlook 2003 not using Word as editor, default msgtype is HTML.
For simplicity we keep the code in the outlook vba editor.
Not working: CreateItemFromTemplate and .Display. Would be perfect, but the
signature appears *above* the body.
This can be worked around by saving without displaying the mail first and
the reopen. Now I have to insert the signature - no problem. But how can
one go to the end of the mail beforehand?? There seems to be nothing like
..Selection or .Range. I don't like SendKeys very much.
Dim m1 As Outlook.MailItem
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim cb As CommandBarControl
Dim i As Inspector
Set m1 = Application.CreateItemFromTemplate("C:\x.oft", _
Application.Session.GetDefaultFolder(olFolderDrafts))
m1.Save
strID = m1.EntryID
m1.Close olSave : Set m1 = Nothing
Set objNS = Application.GetNamespace("MAPI")
Set m1 = objNS.GetItemFromID(strID)
m1.Display ' mail without sig
' *****
' here I need a piece of code to go to the end of the message body
' ******
' Insert Signature
Set i = m2.GetInspector
'Insert->Signature
Set cb = i.CommandBars("Menu Bar").FindControl(, 31145, , , True)
DoEvents ' does not work without for whatever reasons
cb.CommandBar.Controls(1).Execute
Set m1 = Nothing
Another way would be changing .HTMLBody. But it breaks the embedded images.
Dmitry Streblechenko suggested in
http://groups.google.de/group/micro...read/thread/fcbb0f7177cd8785/6f6ecdddf885411c
the use of IHTMLDocument2, but DOM is beyond my knowledge.
Thanks for suggestions
Karsten
the task is to create a new mail from a template (*.oft) with the user's
signature already in place at the end of the mail. Harder then it seems.
Aggravating factors:
- the template is HTML with embedded images (actually copied from Word)
- the user's signature is HTML and usually contains an embedded image
- every user has it's own signature
Version is Outlook 2003 not using Word as editor, default msgtype is HTML.
For simplicity we keep the code in the outlook vba editor.
Not working: CreateItemFromTemplate and .Display. Would be perfect, but the
signature appears *above* the body.
This can be worked around by saving without displaying the mail first and
the reopen. Now I have to insert the signature - no problem. But how can
one go to the end of the mail beforehand?? There seems to be nothing like
..Selection or .Range. I don't like SendKeys very much.
Dim m1 As Outlook.MailItem
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim cb As CommandBarControl
Dim i As Inspector
Set m1 = Application.CreateItemFromTemplate("C:\x.oft", _
Application.Session.GetDefaultFolder(olFolderDrafts))
m1.Save
strID = m1.EntryID
m1.Close olSave : Set m1 = Nothing
Set objNS = Application.GetNamespace("MAPI")
Set m1 = objNS.GetItemFromID(strID)
m1.Display ' mail without sig
' *****
' here I need a piece of code to go to the end of the message body
' ******
' Insert Signature
Set i = m2.GetInspector
'Insert->Signature
Set cb = i.CommandBars("Menu Bar").FindControl(, 31145, , , True)
DoEvents ' does not work without for whatever reasons
cb.CommandBar.Controls(1).Execute
Set m1 = Nothing
Another way would be changing .HTMLBody. But it breaks the embedded images.
Dmitry Streblechenko suggested in
http://groups.google.de/group/micro...read/thread/fcbb0f7177cd8785/6f6ecdddf885411c
the use of IHTMLDocument2, but DOM is beyond my knowledge.
Thanks for suggestions
Karsten