Auto add outlook default signature

G

Guest

I have tried a few things but just can not seem to find the command that
would auto insert the outlook default signature when I create a new email
message using a vbs......i have tried options that read the default .htm
signature file but this never gives the same result with referenced images
not been seen by the receiver. How does outlook do it. It is like outlook
somehow embeds the signature so there are no referencing issues...any help
would be great......if you need to look at my current code I can post that.
 
G

Guest

Thankyou for your response......unfortunately i do not know how to convert
the vba code to vbs.........anyway after looking at the vba code I want to
ask that if I do get what is written in vba code and amend my vbs code to
match.......will my result show images in a signature that are no longer
referenced. Could you have a look at my code and let me know if i am on the
right track and if it would be easy to amend to incorporate the cdo technique

Dim OutApp
Dim OutMail
Dim strbody
Dim SigString
Dim Signature

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile=fso.CreateTextFile ("C:\Program Files\HRS\vbs\Email.htm", vbTrue)
theFile.WriteLine "<HTML>"
theFile.WriteLine "<BODY>"
theFile.WriteLine "Hello Bob<BR>"
theFile.WriteLine "<BR>"
theFile.WriteLine "How are you<BR>"
theFile.WriteLine "<BR>"
theFile.WriteLine "Regards<BR>"
theFile.WriteLine "</BODY>"
theFile.WriteLine "</HTML>"
theFile.Close
Set f = fso.OpenTextFile("C:\Program Files\HRS\vbs\Email.htm",1)

MyHTML = f.ReadAll
f.Close

sfile = "C:\Documents and Settings\Sublime\Application
Data\Microsoft\Signatures\MydefaultSignature.htm"
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
signature=ts.readall
ts.Close

On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "test"
.HTMLBody = MyHTML & "<br><br>" & Signature
.Display
End With

On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
 
S

Sue Mosher [MVP-Outlook]

Sorry, but I don't know what you mean by " images in a signature that are no longer referenced."

There's no reason to write a text file just for the purpose of loading its content into HTMLBody. You can simply build a string variable with the same HTML content.

You also need to take a look at what this expression -- MyHTML & "<br><br>" & Signature -- returns. If you do, you'll see that it is not well-formed HTML content. You'll have internal </html> and <html> tags, etc.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Ok I had a look at the vba code and tried a test. I got it to look at a jpeg
file in my signatures folder but it did not show the image in the resulting
displayed email. Does my converted vbs code look ok....i did my best to try
and convert it to vbs

Dim objApp
Dim l_Msg
Dim colAttach
Dim l_Attach
Dim oSession
Dim oMsg
Dim oAttachs
Dim oAttach
Dim colFields
Dim oField
Dim strEntryID
Set objApp = CreateObject("Outlook.Application")
Set l_Msg = objApp.CreateItem(olMailItem)
Set colAttach = l_Msg.Attachments
Set l_Attach = colAttach.Add("C:\Documents and
Settings\Sublime\Application Data\Microsoft\Signatures\Co
Logo_files\image001.jpg")
l_Msg.Close olSave

strEntryID = l_Msg.EntryID
Set l_Msg = Nothing
Set colAttach = Nothing
Set l_Attach = Nothing
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(1)
Set colFields = oAttach.Fields
Set oField = colFields.Add(CdoPR_ATTACH_MIME_TAG, "image/jpeg")
Set oField = colFields.Add(&H3712001E, "myident")
oMsg.Fields.Add "{0820060000000000C000000000000046}0x8514", 11, True
oMsg.Update

Set l_Msg = objApp.GetNamespace("MAPI").GetItemFromID(strEntryID)

l_Msg.HTMLBody = "<IMG align=baseline border=0 hspace=0 src=cid:myident>"
l_Msg.Close (olSave)
l_Msg.Display

Set oField = Nothing
Set colFields = Nothing
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
Set objApp = Nothing
Set l_Msg = Nothing
 
S

Sue Mosher [MVP-Outlook]

Well, this statement is a bit spare:

l_Msg.HTMLBody = "<IMG align=baseline border=0 hspace=0 src=cid:myident>"

You'd really want to provide the full HTML, including the <html><body> and corresponding end tags and any text you want in the signature.

You might also need to set the CDO Message (oMsg) to Nothing before you try to display it.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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

Top