Link to home
Start Free TrialLog in
Avatar of capturetheflag
capturetheflag

asked on

Generate an automatic email response with an option to add an attachment

I've been sending an "automatic" email messages using the Classic ASP method below, which has worked fine for me until now.  Now I need to send the message with an attachment.  The attachment would be a Word or Excel 2010 document.  I would need to be able to select the document I need to attach to the "automatic" email message because the document info changes constantly. Thanks for the help. Here is my code.
function Reg_Email_Confirm()

mailBody = "This is an automatic email from FIDA. Please do not reply.<BR>" & vbcrlf & _
"____________________________________________________________<BR>" & vbcrlf & _
FirstName & " " & LastName & ", Thank you for registering with FIDA.<BR>" & vbcrlf & _
"We have collected the following information from your registration.<BR>" & vbcrlf & _
"<BR>Name: " & FirstName & " " & LastName & vbcrlf & _
"<BR>Email: " & Email & vbcrlf & _
"<BR>Telephone: " & phone1 & "-" & phone2 & "-" & phone3 & vbcrlf & _
"<BR>Ext: " & Ext & vbcrlf & _
"<BR>IP Address: " & Request.ServerVariables("REMOTE_ADDR") & vbcrlf & _
"<BR><BR>Please <a href='https://vsr.fema.net/FIDA/default.asp'>access FIDA </a> and log in using the following: " & vbcrlf & _
"<BR>Email: " & Email & vbcrlf & _
"<BR>Password: " & Password & vbcrlf & _
"<BR><BR>Once you logged in you may change your password to something that is easier for you to remember via the 'Update User Profile' link." & vbcrlf & _
"<BR><BR>If you have any problems you can contact " & Application("VANPSC-REPORTS-EMAIL") & " for help.<BR><BR>" & vbcrlf & vbcrlf & _
"Thanks,<BR>" & vbcrlf & _
"FIDA" & vbcrlf


               mailFrom = Application("VANPSC-REPORTS-EMAIL") 
               mailSubject = "FIDA Registration Confirmation Email"
               mailTo = lcase(Email)

               Set conn = Server.CreateObject("ADODB.Connection") 
               conn = Application("FIDAConnectString")

               Set cmd = Server.CreateObject("ADODB.Command")
               cmd.CommandType = Application("adCmdStoredProc")
               cmd.ActiveConnection = conn
               Set rs = Server.CreateObject("ADODB.Recordset") 
               'cmd.Properties("PLSQLRSet") = TRUE
               
               cmd.CommandText = "FIDA.MAIL_API.SEND"    
               
               cmd.Parameters.Append cmd.CreateParameter("p_sender_i", Application("adVarChar"), Application("adParamInput"), 100, mailFrom)
               cmd.Parameters.Append cmd.CreateParameter("p_recipients_i", Application("adVarChar"), Application("adParamInput"), 1000, mailTo)
               cmd.Parameters.Append cmd.CreateParameter("p_subject_i", Application("adVarChar"), Application("adParamInput"), 500, mailSubject)
               cmd.Parameters.Append cmd.CreateParameter("p_mime_type_i", Application("adVarChar"), Application("adParamInput"), 100, "text/html")
               cmd.Parameters.Append cmd.CreateParameter("p_message_i", Application("adVarChar"), Application("adParamInput"), 1000, mailBody)
               
               cmd.execute
               
               if err.number <> 0 then 
                              Response.Write "Error encountered: " & Err.Description
                              response.end()
               end if

               set cmd = nothing

end function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of capturetheflag
capturetheflag

ASKER

Hello padas,

Thanks for your help.  It looks like the line of code for the attachment is hard coded. You can only attach readme.txt.
How would you make it possible, to allow the user to choose the attachment, they want to put with the automatic email response?  Thanks.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help
Glad it worked out.