Problems with CDO or SMTP

Posted on 2004-04-20
Last Modified: 2011-10-03
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>"

With iMsg
            .Configuration = iConf
            .From = FromName
            .Sender = FromEmail
            .To =  ToName
            .BCC = EmailBCCAddress
            .ReplyTo = EmailReplyAddress
            .Subject = UserMessage
            .HTMLBody = body
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.

Question by:prodier

Expert Comment

ID: 10871258
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>"


Author Comment

ID: 10871304
HTML supports both single and double quotes, but i tried your suggestion anyway and get the same result
LVL 53

Expert Comment

ID: 10875472
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.

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 = ""
.To = ""
.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
End With
Debug.Print "Message sent."
End Sub

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center


Expert Comment

ID: 10875600
what about
body = body &  "<a href=" & chr(34) & "clickhere" & chr(46) & "html" & chr(34) & ">click here</a>"

Author Comment

ID: 10878636
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

Expert Comment

ID: 10915147
Maybe this'll help :) i didn't try it ,, but it may work
try to change the Dot (.) into "%2e"
 body = body &  "<a href='clickhere%2ehtml'>click here</a>"
hope this is not too dumb ,, lol

Accepted Solution

Netminder earned 0 total points
ID: 11297176
Closed, 500 points refunded.
Site Admin

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question