Connect with Expertise | Find Experts, Get Answers, Share Insights

CDOSYS HTML e-mail with attachment

 
Join Date: Feb 2010
Posts: 6
#1: Feb 8 '10
I want to e-mail a website, and include a .pdf attachment. I am able to e-mail the website using the code below (i only changed the url of the attachment for privacy), however, the attachment arrives with no file extension and the name "mime" If I rename this file with a .pdf extension, the file displays as normal. If I use this same code below, only with a basic textbox, the attachment retains it's file extension, however, the name of the file changes. I need to send the e-mails using html (which works great), but I'd like to be able to maintain the name of the file, as well as the file extension, of the attachment. Any help would be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Set myMail = Server.CreateObject("CDO.Message")
  3.  
  4. %>
  5.  
  6. <%
  7. url = Request.Form("empURL")
  8. %>
  9.  
  10. <%
  11. with myMail
  12. .Subject = Request.Form("Subject")
  13. .From = Request.Form("From")
  14. .To = Request.Form("To")
  15. .Cc = ("hr")
  16. .CreateMHTMLBody url
  17. .AddAttachment "http://www.mywebsiteurlchanged.com/StandardsManual082508.pdf"
  18. end with
  19. %>
  20.  
  21. <%
  22. myMail.Send
  23. set myMail = Nothing
  24. %>
  25. <html>
  26. Mail sent to 
  27. <%
  28. Dim sent
  29. sent = Request.Form("To")
  30. Response.Write(sent)
  31. %></html>

jhardman's Avatar
E
M
C
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,967
#2: Feb 9 '10

re: CDOSYS HTML e-mail with attachment


try to send the attachment file path as the local path, I think that will clear up the problem. you can use server.mappath to get the correct directory.

Jared
Reply

Tags
asp, asp attachment, attachment, cdosys, mime