Solved

Adding attachments to html mails that use Server.CreateObject("SMTPsvg.Mailer")

Posted on 2004-08-27
6
695 Views
Last Modified: 2012-06-21
Hi experts,

Fairly straight forward question I hope - we've got an html email that goes out no problem, but we need to add an attachment to it - when we do this it sends the email in plain text - is this a problem with the object?

Let me know if you'd like me to post the code up.

Many Thanks,
0
Comment
Question by:pjordanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Assisted Solution

by:j2nku
j2nku earned 200 total points
ID: 11910737
http://www.aspfaq.de/index.asp?FID=108&ELE=9400 (sorry, in german, but code seems OK)
http://www.codeproject.com/asp/smtpmaildelivery.asp?df=100&forumid=3546&exp=0&select=583140 (search for word "attachment")

Hope these help you (really simple), from an example of the second URL:

Call myMail.AttachFile("\\server\bill_photos\bill_wife_nude.jpg", "BILL_WIFE_NUDE.JPG")

where myMail is the object name you created with Server.CreateObject("SMTPsvg.Mailer").
0
 

Author Comment

by:pjordanna
ID: 11911004
Hi j2nku,

Thanks for your comments - my code already works in that it sends an html email or adds an attachment, but I'm struggling to get it to do both html and add the attachment - here is the code to show what i mean

Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
strURL = "http://www.abc.co.uk/xyz/letter.asp?polNo=" & polNo & "&email=yes"

objXML.Open "GET", strURL , false

objXML.Send

If Err.Number = 0 Then               'no errors
If objXML.Status = 200 then          'url is valid
strOpen = objXML.ResponseText

Else
Response.Write "Incorrect URL"
End if
Else
Response.Write Err.Description
End If

Set objXML = Nothing
      
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.ContentType = "text/html"
Mailer.FromName   = "ME!"
Mailer.FromAddress= "sales@abc.com"
Mailer.RemoteHost = "mail.abc.net"
Mailer.AddRecipient trim(email), trim(email)
Mailer.Subject = "confirmation of order number " & polNo
'Mailer.AddAttachment "g:\websites\abc\htdocs\pol.pdf"
Mailer.BodyText = strOpen

if Mailer.SendMail then response.write("mail sent!<br>")
      
      
end if      
0
 

Author Comment

by:pjordanna
ID: 11911020
the attachment line in remarked out at the moment - if i add it it works but turns the html email to plain text.....
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:j2nku
ID: 11911188
After

Mailer.ContentType = "text/html"

Be sure you also write

Mailer.BodyFormat = 0 ' (0 = HTML, 1 = Text)

Also, if it doesn't help, try:

Mailer.MailFormat = 0 ' (0 = Mime, 1 = Text)
0
 

Author Comment

by:pjordanna
ID: 11913010
Hi there - i'm getting Object doesn't support this property or method errors with both those lines
0
 
LVL 1

Accepted Solution

by:
_sculpt earned 300 total points
ID: 11919469
Hi pjordanna,

The Mailer.ContentType = "text/html" is ignored if you have attachments...
See documentation: http://www.serverobjects.com/comp/Aspmail4.htm

I don't think it is possible to use ASPMail to send an HTML email with an attachment unfortunately. Do you have the option of using another mail component or perhaps CDONTS?


0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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