CDOSYS HTML e-mail with attachment

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jptelthorst
    New Member
    • Feb 2010
    • 6

    CDOSYS HTML e-mail with attachment

    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.

    Code:
    <%
    Set myMail = Server.CreateObject("CDO.Message")
    
    %>
    
    <%
    url = Request.Form("empURL")
    %>
    
    <%
    with myMail
    .Subject = Request.Form("Subject")
    .From = Request.Form("From")
    .To = Request.Form("To")
    .Cc = ("hr")
    .CreateMHTMLBody url
    .AddAttachment "http://www.mywebsiteurlchanged.com/StandardsManual082508.pdf"
    end with
    %>
    
    <%
    myMail.Send
    set myMail = Nothing
    %>
    <html>
    Mail sent to 
    <%
    Dim sent
    sent = Request.Form("To")
    Response.Write(sent)
    %></html>
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    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

    Comment

    Working...