1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ASP Form Mail with File Attachment?

Discussion in 'C#' started by nicknick, Jan 23, 2007.

  1. #1
    I usually do forms in PHP but a client has an ASP site and needs to have forms with file attachments. I was wondering if anyone could help me out. Everything works just fine except that the files won't send.

    Here is the code that sends in ASP and thank you.
    SEMrush
    	<!-- ASP Mail Send Page -->
    			<%
    				Dim bodyText, order, client, info 
    				client = "Thank you for contacting us."
    				order = "An order has been placed."
    				Info = "Contact Info"  & Chr(13) & Chr(13) & "Name: " & Request.QueryString("name") & Chr(13) & "Position: " & Request.QueryString("position")& Chr(13) & "Company: " & Request.QueryString("compName") & Chr(13) & Chr(13) & "Address: " & Chr(13) & Request.QueryString("Address1") & Chr(13) & Request.QueryString("Address2") & Chr(13) & Chr(13) & "City: " & Request.QueryString("city")& Chr(13) & "Province: " & Request.QueryString("Prov") & Chr(13) & "Country: " & Request.QueryString("Country") & Chr(13) & "Postal Code: " &  Request.QueryString("code") & Chr(13) & "E-mail: " & Request.QueryString("email") & Chr(13) & "Phone Number: " & Request.QueryString("Phone_Number") & Chr(13) & "Message: " & Request.QueryString("resume") & Chr(13)
    				
    			
    				Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
    				Mailer.RemoteHost  = "smtp.example.com"
    				Mailer.FromName    = "www.example.com"
    				Mailer.FromAddress = "test@example.com"
    				Mailer.AddRecipient Request.QueryString("email"),Request.QueryString("email")
    				Mailer.Subject = "Thank you for contacting us!"
    				Mailer.BodyText = Info
    				Mailer.SendMail
    
    				
    
    				Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
    				Mailer.RemoteHost  = "smtp.example.com"
    				Mailer.FromName    = Request.QueryString("Name")
    				Mailer.FromAddress = Request.QueryString("email")
    				Mailer.AddRecipient "me@example.com","me@example.com"
    				Mailer.Subject = "Test Email"
    				Mailer.BodyText = Info
    				Mailer.SendMail
    
    			%>
    Code (markup):
     
    nicknick, Jan 23, 2007 IP
    SEMrush
  2. intothemiddle

    intothemiddle Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hey nicknick,

    I can't see anywhere in your code where there is anything to attach a file/document.

    Though it'll depend on both your mail components capabilities to allow it, plus which one it supports:

    http://www.tek-tips.com/faqs.cfm?fid=2962 < is a good starting point.

    Your current code just tries to send 2 emails out.
    Request.QueryString("email") is checking for something from a previous Form using GET and email as a parameter. EG:
    sendmail.asp?email=myemail@hotmail.com

    In your script other things such as position are being added;
    sendmail.asp?email=myemail@hotmail.com&position=winner
     
    intothemiddle, Jan 24, 2007 IP
  3. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi intothemiddle. Thank you for the reply. You're right. There is no info on that page that sends an attachment. I am just not sure how to make it work. I had a look at the page you sent but the whole ASP thing is beyond me. I think I'm going to post in the buy sell trade forum to see if anyone would like to modify that code for $20 or something. Thanks again for the reply.
     
    nicknick, Jan 24, 2007 IP
  4. intothemiddle

    intothemiddle Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi NickNick,

    Well I'm happy to help for free by all means, but you need to tell me which component your server supports for email and I'll supply you with something.
     
    intothemiddle, Jan 24, 2007 IP
  5. rmk

    rmk Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From="mymail@mydomain.com"
    myMail.To="someone@somedomain.com"
    myMail.TextBody="This is a message."
    myMail.AddAttachment "c:\mydocuments\test.txt"
    myMail.Send
    set myMail=nothing
    %>
    
    Code (markup):
    w3schools.com/asp/asp_send_email.asp
     
    rmk, Feb 24, 2007 IP
  6. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks guys. I ended up hiring someone to get this going for me. They came up with something that uploads a file to the server and then mails and deletes the file. It works very well. thanks again for the replies.
     
    nicknick, Feb 24, 2007 IP
  7. vaibhavplus

    vaibhavplus Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Dear Friend,
    Can you please share it with me if possible, how did you implemented the feature of sending an attachment with the asp page?

    Best!
    Webb
     
    vaibhavplus, Nov 26, 2007 IP
  8. intothemiddle

    intothemiddle Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The response posted by RMK above gives an example of a CDO attachment which should meet your requirements or try a component to do so;
    http://www.aspemail.com/manual_03.html

    As above, both of these work but will need to be configured (remote hosts, etc) to function properly.

    Rob
     
    intothemiddle, Nov 29, 2007 IP