Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-08-27
6
Medium Priority
?
701 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 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