Solved

ASPMailer AddAttachment from Web Form

Posted on 2004-04-17
3
347 Views
Last Modified: 2008-02-26
Hello,

Using a Web form I have a field that allows a user to attach a file and upon submit an email is generated and the file is attached to that email.  But I am receiving an error - The Path parameter for the MapPath method must be a virtual path. A physical path was used.

Here is my code:

<%
  Dim Name
  Dim EMail
  Dim Phone

  Name = Request.Form("txtfName")
  EMail = Request.Form("txtemail")
  Phone = Request.Form("txtPhone")
  file = Request.Form("fResume")

  Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
  Mailer.FromName   = Name
  Mailer.FromAddress = Email
  Mailer.RemoteHost = "mail.website.com"
  Mailer.AddRecipient "info@website.com", "info@website.com"
  Mailer.Subject = "Submitted file"
  Mailer.AddAttachment (Server.MapPath(file))
  Mailer.ContentType = "text/html"
  Mailer.BodyText = "<html><body>Hello You, <br>" & Name & " is interested in the following:  Attached is their document<BR></body></html>"

  strMsgFooter = vbCrLf & "End Of Information Sent"
  Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter


  if Mailer.SendMail then
      Response.Write ""
  else
      Response.Write "<FONT COLOR='red'>Mail send failure. Error was</FONT> " & Mailer.Response
  end if

%>
0
Comment
Question by:rudyflyer
  • 2
3 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
I don't think that will work. In order for ASPeMail to send the attachment, it has to exist on the server, not the client. Sio, what you have to do is to upload the attachment to the server first and then send the attachment.

Fritz the Blank
0
 

Author Comment

by:rudyflyer
Comment Utility
How would I do that?
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 250 total points
Comment Utility
You will need to have some sort of upload component or to use a pure code (i.e., no component) solution. Here are a few to get you started:

components:

http://www.aspupload.com/
http://aspalliance.com/dundas/default.aspx
http://fileup.softartisans.com/fileup-131.aspx

code only:

http://www.asp101.com/articles/jacob/scriptupload.asp#buffering

Fritz the Blank
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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 information …
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…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

11 Experts available now in Live!

Get 1:1 Help Now