Solved

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

Posted on 2004-08-27
6
679 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
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 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

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

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

18 Experts available now in Live!

Get 1:1 Help Now