PDA

View Full Version : Unknown Symbols keep appearing!!



IrishCharm
05-14-2008, 05:01 AM
Hi,

I have an automated email function which sends out a string message and attaches a html signature to the end of the mail (saved in c drive as mysig).

However there are funny symbols which keep appearing between the signature and message and i can not understand it. Any help would be great - i am using Excel and Outlook 2003

Kind regards,

Sarah

Sub SendMessage()

SigString = "C:\Documents and Settings\duffsa\Application Data\Microsoft\Signatures\MySig.htm"
str_subject = "HELLO WORLD"
str_body = "TEST MAIL"
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(SigString).openastextstream(1, -2)
Signature = ts.readall
Set objOutlook = CreateObject("outlook.application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("MY EMAIL ADDRESS")

.Subject = str_subject
.htmlBody = "<html><body>" & str_body & "<br><br>" & Signature

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
.Display

End With

End Sub

IrishCharm
05-15-2008, 01:45 AM
Hi,

Anyone out there with ideas re the above?

tpoynton
05-15-2008, 07:20 AM
You should probably close the body and html tags in .htmlbody, although I'm not absolutely sure that will make a difference.

If your signature contains html code, that could be causing some problems, too. troubleshoot it by seeing what is in the Signature variable (msgbox Signature) to determine if the problem is there, or elsewhere.

You might want to have your signature be a text file instead of html.

IrishCharm
05-16-2008, 03:38 AM
Thanks for that - i tried but am unable to get the code correct to enclose a string into .html format. would you have any idea how this is done correctly? i keep getting errors and blanks when i try.

sarah

rory
05-16-2008, 07:01 AM
I was actually working on something similar to this for someone else on another forum recently, and came to the conclusion that it's easier to create a template in Outlook with your signature plus any boilerplate text and a placeholder for any text you want included in the body (e.g. you add |Replace Data Here| in the relevant location)
You can then use the Outlook Application's CreateItemFromTemplate method to create a new email based on your template, then use a simple Replace function to put whatever text you want in place of the placeholder text in the HTMLBody. Seems to work well in my testing (albeit limited).