Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

Problems with CDO or SMTP

I'm using CDO for Win2k and IIS Smtp to send HTML formated emails through a visual basic application.
Only probelm is the CDO object  or smtp server seems to be removing characters from the HTML Text
for example in the code i would have

iConf = New Configuration
iMsg = New Message
dim body as string

body = "<HTML>"
...
body = body &  "<a href='clickhere.html'>click here</a>"
...
body = body &  "</HTML>"

'APPLY THE SETTINGS TO THE MESSAGE
With iMsg
            .Configuration = iConf
            .From = FromName
            .Sender = FromEmail
            .To =  ToName
            .BCC = EmailBCCAddress
            .ReplyTo = EmailReplyAddress
            .Subject = UserMessage
            .HTMLBody = body
            .Send()
End With

But when i send the message the link in the body looks like:
<a href='clickherehtml'>click here</a>

The period is missing from the href attribute. It seems to do this for no reason.

I know its not the email client removing the period because i've sent it to a couple different clients and get the same result each time.

TIA
0
prodier
Asked:
prodier
1 Solution
 
sbennettsCommented:
Don't you need double quotes around the attribute in HTML.  Replace your single quotes with TWO double quotes and try again.

So in your VB app, do something like...
-----------------------------------------------
iConf = New Configuration
iMsg = New Message
dim body as string

body = "<HTML>"
...
body = body &  "<a href=""clickhere.html"">click here</a>"
...
body = body &  "</HTML>"
-----------------------------------------------

Regards
Simon
0
 
prodierAuthor Commented:
HTML supports both single and double quotes, but i tried your suggestion anyway and get the same result
thanks
0
 
DhaestCommented:
Looking at the next article, i don't think it's necesarry to include the "html"-tag because it won't be shown in the email.

USING HTML FORMATTING
If you want to include formatting in the body text, you can use HTML formatting.With HTML, you can specify the font style, add bold or italic, or use bulleted lists.In fact, you can use just about any formatting available in HTML. To use HTML formatting in body text, you set the HTMLBody property to a legitimate HTML string. For example, the following code sample uses HTML formatting to create body text with a header, a rule, italic, and special font styles in the text:
msg.HTMLBody = _
"<H1>Check this out!</H1>" & _
"<HR><i>Look</i>" & _
" at this " & _
"<font color=red size=12>cool</font>" & _
" HTML message."
When you create an HTML body, by default CDO also generates a plain-text version of the body text. The plain-text version of the body uses the same text as the HTML body but without any special HTML formatting. This ensures that clients unable to process HTML-formatted messages can still read the message. If you would rather not automatically generate a plain-text version of the body text, set the AutoGenerateTextBody property to False. Then, if you prefer to create a plaintext body, you can do so by setting the TextBody property to the value you want.
For example, Listing 6.2 shows how to create a message with two different formats
for the body text.
Listing 6.2 Generate a message with both a text body and an HTML body.
Public Sub CreateSeparateTextandHTML()
' Use both an HTML and plain text
' version for body text formatting.
' If you are using VBScript, use this With:
' With CreateObject("CDO.Message")
With New CDO.Message
.From = "mindy@domain.com"
.To = "peter@domain.com"
.Subject = _
"This message has two different body text versions"
' Generate body text for plain text viewers
.TextBody = _
"You're missing out by not supporting HTML!"
' Generate body text for HTML capable viewers
.HTMLBody = _
"<H1>Check this out!</H1>" & _
"<HR><i>Look</i>" & _
" at this " & _
"<font color=red size=12>cool</font>" & _
" HTML message."
' Send the message
.Send
End With
Debug.Print "Message sent."
End Sub

Source: http://www.thaifast.com/Microsoft_Books/Sample/607729c06.pdf
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
JTrainCommented:
what about
body = body &  "<a href=" & chr(34) & "clickhere" & chr(46) & "html" & chr(34) & ">click here</a>"
0
 
prodierAuthor Commented:
The issue is that the SMTP server is mangling parts of the HTML.
The HTML is properly formatted, as i've ran it through a XHMTL parser, when I assigned it to the .HTMLBody Property of the CDO Object.
The CDO object then puts a .eml file in the c:\inetpub\mailroot\pickup folder, the IIS SMTP watched this folder for files.
At this point the HTML in the .eml file is still fine, no periods removed.
After the ISS smtp server finds the file it moves it to the c:\inetpub\mailroot\queue folder, where it sits until the email is sent.
The file that is put in the c:\inetpub\mailroot\queue folder has the period removed
Its like the iss smtp is having trouble when a period is the 72 second character
I know a period is supposed to signal the end of the message in a smtp conversation maybe that has something to do with it
0
 
OHDev2004Commented:
Maybe this'll help :) i didn't try it ,, but it may work
try to change the Dot (.) into "%2e"
like
 body = body &  "<a href='clickhere%2ehtml'>click here</a>"
hope this is not too dumb ,, lol
OHDev
0
 
NetminderCommented:
Closed, 500 points refunded.
Netminder
Site Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now