Solved

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

Posted on 2004-08-27
6
674 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
  • 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

26 Experts available now in Live!

Get 1:1 Help Now