?
Solved

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

Posted on 2004-08-27
6
Medium Priority
?
706 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 800 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
Independent Software Vendors: 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 1200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

864 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