Solved

Problems with CDO or SMTP

Posted on 2004-04-20
9
588 Views
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>"

'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
Comment
Question by:prodier
9 Comments
 
LVL 2

Expert Comment

by:sbennetts
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>"
-----------------------------------------------

Regards
Simon
0
 

Author Comment

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

Expert Comment

by:Dhaest
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.

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

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

Author Comment

by:prodier
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
0
 
LVL 7

Expert Comment

by:OHDev2004
ID: 10915147
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
 
LVL 5

Accepted Solution

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now