Re: sample ASP XP Mail component

From: Lord Merlin (SP4M_Rudi_at_SP4M_Bonzai.org.za_SP4M)
Date: 04/17/04


Date: Sat, 17 Apr 2004 15:03:30 +0200


"Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
news:uCuKJ2ZIEHA.2144@TK2MSFTNGP12.phx.gbl...
: Yes, CDO can send mail via a remote SMTP server.
: http://www.aspfaq.com/2026
:
: You can send in HTML format, though I strongly recommend sending a plain
: text version as well (since many people, myself included, set their e-mail
: client to show plain text only).
: http://www.aspfaq.com/2474
:
: As for embedding images, one way to accomplish that is having an absolute
: link to an online resource, e.g.
:
: <img src="http://yourserver/yourimage.gif">
:
: The other would be to create an HTML page that looks exactly how you want
: the e-mail to look, then do this:
:
: <%
: CONST SMTPServer = "your.mail.server"
: CONST cdoURL = "http://schemas.microsoft.com/cdo/configuration/"
:
: FromAddress = "you@yourdomain.com"
: FromName = "Your Name"
: ToAddress = "to@theirdomain.com"
: ToName = "Their Name"
: Subject = "The subject of the message"
: ThePageYouWantToMimic = "http://www.microsoft.com/"
:
: set cdoM = CreateObject("CDO.Message")
: set cdoC = CreateObject("CDO.Configuration")
:
: Set cdoF = cdoC.Fields
: With cdoF
: .Item(cdoURL & "sendusing") = 2
: .Item(cdoURL & "smtpserver") = SMTPServer
: .Item(cdoURL & "smtpconnectiontimeout") = 10
: .Update
: End With
:
: With cdoM
: Set .Configuration = cdoC
: .CreateMHTMLBody ThePageYouWantToMimic
: .From = FromAddress
: .To = ToAddress
: .Subject = Subject
: .Send
: End With
:
: Set cdoM = Nothing
: Set cdoS = Nothing
: Set cdoF = Nothing
: %>
:
: I'm not sure how that would appear in non-Microsoft e-mail clients (note
: that many will STILL see plain text and images as attachments), and I'm
not
: going to download and install one to check. I think it's pretty invasive
: for you to force users to store your HTML on their machine, but I've been
: down this road before. And generally, it is frowned upon in a Microsoft
: group to use a berating acronym like M$.
:
: --
: Aaron Bertrand
: SQL Server MVP

I know what you are saying is true, but the client has requested, and insist
that he keeps his branding, and needs his images embedded in order to keep
his buttons / borders / logos etc in the mail, the same way the website
looks! Even though he gets an odd 60 or so bounces because of companies not
accepting such emails.

I just got a question, which I couldn't seem to figure out. How do I embed
an image with your example? the problem I sit with, is that a lot of users
download email, and disconnect from the internet, thus an absolute link
(www.mysite/images/logo.gif) won't work, as these images will only be
downloaded once the email has been opened, and it tries to connect to the
server.

with CDONTS, I can do this very well:

bodytext = bodytext & "<td align=center><a href='" & domain &
"/kickmeto.asp?page=questionaire_respond.asp&emailrespond=yes&userid=" &
userid & "&questionaireid=2&companyid=" & companyid & "&response=5"
  bodytext = bodytext & "&commentid=" & commentid &
"&subcomment=yes&subcommentid=" & subcommentid & "'>"
  bodytext = bodytext & "<img src=""face_m2.gif"" width='24' height='23'
border=0></a></td>"
 End If
 bodytext = bodytext & "</tr>"
 bodytext = bodytext & "<tr align=center bgcolor='#FFFFFF' ><td
width='20%'><font size=2>Over The Moon</td><td width='20%'><font
size=2>Quite Impressed</td><td width='20%'><font size=2>Indifferent</td><td
width='20%'><font size=2>Not Impressed</td><td width='20%'><font
size=2>Utterly Disgusted</td></tr>"

on error resume next
 Set Mailer = Server.CreateObject("CDONTS.NewMail")
 mailer.AttachURL file_path + "face_0.gif", "face_0.gif"
 mailer.AttachURL file_path + "face_1.gif", "face_1.gif"
 mailer.AttachURL file_path + "face_2.gif", "face_2.gif"
 mailer.AttachURL file_path + "face_m1.gif", "face_m1.gif"
 mailer.AttachURL file_path + "face_m2.gif", "face_m2.gif"

  Mailer.From = strFrom
  Mailer.Importance = 2
  Mailer.BodyFormat = 0
  Mailer.MailFormat = 0
  Mailer.To = email
  Mailer.Body = bodytext

  Mailer.Send

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689
Greater love has no one than this, that he lay down his life for his friends
(John 15:13).

Loading