Jump to content

AspEmail Attachment


-=j0nnyr0773n=-

Recommended Posts

Hey all, I have created an AspEmail form that works flawlessly. Also on the same page I have created two fields that you can browse your local pc and click upload to upload two files to a directory called /upload on the web server via ASPupload. Now I want to be able to attach those two specific files to the mail form when it is submitted to the server. My predicament is that all the documentation I have come across says you need to specifically state the exact path to the filenames to be attached eg...

Mail.AddAttachment="/upload/filename.txt"
Now that is fine, I understand that but in my situation users will be uploading resumes and headshots to the server from their own pc's and the filenames and types will be different everytime. The locations will be the same but the names and types different. Is there a way to tell the form to attach the two last uploaded files to the message? Here is a sample of my code:
<% @LANGUAGE=VBSCRIPT %><HTML><BODY><%strHost = "mail.accuwebhosting.biz"If Request("SUBMIT") <> "" ThenSet Mail = Server.CreateObject("Persits.MailSender")Mail.Host = strHostMail.From = Request("email")Mail.FromName = Request("email")Mail.AddAddress "webform@selfcenteredproductions.com"Mail.Subject = Request("Self Centered Productions Webform Inquiry")Mail.Body = "First Name: " & request("firstname") & vbCrlf & "Last Name: " & request("lastname") & vbCrlf & "Company Name: " & request("company") & vbCrLf & "Trade: " & request("trade") & vbCrLf & "Home Phone: " & request("telephone") & vbCrLf & "Cell Phone: " & request("cellphone") & vbCrLf & "Location Residing: " & request("location") & vbCrLf & "Comments and Messages: " & request("comments")strErr = ""bSuccess = FalseOn Error Resume NextMail.SendIf Err <> 0 ThenstrErr = Err.DescriptionelsebSuccess = TrueEnd IfEnd Ifresponse.redirect "resume.htm"%></BODY></HTML>
Thank you in advance for any insight. -=j0nnyr0773n=- :)
Link to comment
Share on other sites

I figured it out, here it is in case anyone else wants to know. Instead of making a html form that posts to an .ASP file, just combine the two in one like so. Also there is no need to separately upload the files before attaching them to the message, this code does it all at once, to see the finished product go to http://www.selfcenteredproductions.com/resume.asp :)

<% @LANGUAGE=VBSCRIPT %> <%    strHost = "mail.accuwebhosting.biz"  Set Upload = Server.CreateObject("Persits.Upload")  Upload.IgnoreNoPost = True  Upload.SaveVirtual "/upload/"  If Upload.Form("SUBMIT") <> "" Then      Set Mail = Server.CreateObject("Persits.MailSender")      Mail.From = Upload.Form("email")      Mail.FromName = Upload.Form("email")      Mail.Host = strHost      Mail.Subject = "Self Centered Productions Webform Inquiry"      Mail.Body = "First Name: " & Upload.Form("firstname") & vbCrlf & "Last Name: " & Upload.Form("lastname") & vbCrlf & "Company Name: " & Upload.Form("company") & vbCrLf & "Trade: " & Upload.Form("trade") & vbCrLf & "Home Phone: " & Upload.Form("telephone") & vbCrLf & "Cell Phone: " & Upload.Form("cellphone") & vbCrLf & "Location Residing: " & Upload.Form("location") & vbCrLf & "Comments and Messages: " & Upload.Form("comments")      Mail.AddAddress "webform@selfcenteredproductions.com"      If Not Upload.Files("Attachment") Is Nothing Then        Mail.AddAttachment Upload.Files("Attachment").Path  Mail.AddAttachment Upload.Files("Attachment1").Path      End If      Mail.Send      Response.Redirect "success.htm"  End If%><HTML><HEAD><TITLE>Self Centered Productions - Mission Statement</TITLE><STYLE>body {background-color:#000000; color:#FFFFFF; font-family:arial;}</STYLE></HEAD><BODY><TABLE border="0" width="725" cellpadding="0" cellspacing="0" align="center"> <TR>  <TD align="center" valign="top">  <TABLE border="0" width="725">    <TR>    <TD align="center" valign="top">    <IMG src="images/toplogo.gif">    </TD>    </TR>    <TR>    <TD align="center">    <HR color="#3366FF" width="660">    </TD>    </TR>        <TR>    <TD align="center">    <IMG src="images/cast_crew.gif">    </TD>    </TR>    <TR>    <TD> </TD>    </TR>    <TR>    <TD align="center">      <FORM action="resume.asp" method="post" ENCTYPE="multipart/form-data">      <TABLE border="0" cellpadding="3" cellspacing="0" width="725">      <TR>        <TD>First Name:</TD>        <TD align="right"><INPUT TYPE="text" NAME="firstname" SIZE="15" maxlength="40"></TD>        <TD> </TD>        <TD>Last Name:</TD>        <TD align="right"><INPUT TYPE="text" NAME="lastname" SIZE="15" maxlength="40"></TD>      </TR>      <TR>        <TD>Company Name:</TD>        <TD align="right"><INPUT TYPE="text" NAME="company" SIZE="15" maxlength="100"></TD>        <TD> </TD>        <TD>Trade:</TD>        <TD align="right"><INPUT TYPE="text" NAME="trade" SIZE="15" maxlength="50"></TD>      </TR>      <TR>        <TD>Home Phone Number:</TD>        <TD align="right"><INPUT TYPE="text" NAME="telephone" SIZE="15" maxlength="15"></TD>        <TD> </TD>        <TD>E-mail Address:</TD>        <TD colspan="2" align="right"><INPUT TYPE="text" NAME="email" SIZE="15" maxlength="100"></TD>      </TR>      <TR>        <TD>Cell Phone Number:</TD>        <TD align="right"><INPUT TYPE="text" NAME="cellphone" SIZE="15" maxlength="15"></TD>        <TD> </TD>        <TD>Location Residing:</TD>        <TD align="right"><INPUT TYPE="text" NAME="location" SIZE="15" maxlength="100"></TD>      </TR>      <TR>        <TD colspan="5"> </TD>      </TR>      <TR>         <TD colspan="2" align="center">Comments and Messages:</TD>        <TD colspan="3" align="center"><TEXTAREA NAME="comments" ROWS="3" COLS="50"></TEXTAREA>      </TR>      <TR>        <TD>Upload Headshot</TD>        <TD><INPUT type="file" name="Attachment"></TD>        <TD> </TD>        <TD>Upload Resume</TD>        <TD><INPUT type="file" name="Attachment1"></TD>      </TR>            <TR>        <TD colspan="5" align="right">                <INPUT TYPE="submit" SUBMIT NAME="SUBMIT" VALUE="Submit Information">        </TD>      </TR>      </TABLE>      </FORM></TD>    </TR>              </TD>    </TR>    <TR>    <TD colspan="2"> </TD>    <TR>    <TR>    <TD colspan="2">    <TABLE border="0" cellpadding="0" cellspacing="0">      <TR>      <TD align="center" height="100" width="375">      <IMG src="images/homesmall.gif" border="0" name="home"        onMouseover="document.home.src='images/homebig.gif';"        onMouseout="document.home.src='images/homesmall.gif';"        onClick="document.location='index.htm';" style="cursor:pointer;">      </TD>      <TD align="center" width="375">      <IMG src="images/missionsmall.gif" border="0" name="mission"        onMouseover="document.mission.src='images/missionbig.gif';"        onMouseout="document.mission.src='images/missionsmall.gif';"        onClick="document.location='mission.htm';" style="cursor:pointer;">      </TD>      </TR>    </TABLE>    </TD>    </TR>  </TABLE>  </TD> </TR></TABLE></BODY></HTML>
-=j0nnyr0773n=- :)
Link to comment
Share on other sites

  • 1 month later...
I figured it out, here it is in case anyone else wants to know.  Instead of making a html form that posts to an .ASP file, just combine the two in one like so.  Also there is no need to separately upload the files before attaching them to the message, this code does it all at once, to see the finished product go to http://www.selfcenteredproductions.com/resume.asp  :)-=j0nnyr0773n=- :)

I am new at all these server scripting languages, so bear with me. I am trying to do the same thing with a form, i.e. send comments and conctact info to me via an email form on my website.With .ASP, do you have to create the form page and then also create the "action" page. I am trying to follow your code from that link you provided. However, I didn't see the code you show in this post. Is that the code that you have for when a person submitts his or her info to your site and it's just uploaded to your host service?I still haven't been able to figure out how to send the info I request of the user (from the form) to my email via the form in HTML. I have code for the form, but I guess the trouble I am having is with the "action" code.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...