To send an email, I use this function:
- Code: Select all
<%
sub SendEmail(ToMe, FromMe, Blind, Copy, MySubject, MyBody, Attachment)
Dim MyMail
Set MyMail = Server.CreateObject("CDONTS.NewMail")
Dim fs,f
MyMail.From = FromMe
MyMail.To = ToMe
MyMail.BCC = Blind
MyMail.CC = Copy
MyMail.Subject = MySubject
MyMail.Body = MyBody
MyMail.BodyFormat = 1
MyMail.MailFormat = 1
if Attachment <> "" then
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(Server.MapPath(Attachment))
MyMail.AttachFile f
end if
MyMail.Send
' response.write FromMe & ", " & ToMe & ", " & Blind & ", " & Copy & ", " & MySubject & ", " & MyBody
Set MyMail = Nothing
set f=nothing
set fs=nothing
end sub
%>
When you have a checkbox like this:
<input type="checkbox" name="SendPFD" value="true">
on the
ASP page, I have found, you have to say
<% if response.form("SendPDF") = True then do some stuff %>
to call the email function
<%
attachment = "string that is the full file location of the file or the relative file location of the file."
sendemail toEmail, FromEmail, BCCEmail, CCEmail, Subject, bodyText, attachment
%>
see this:
http://www.w3schools.com/asp/asp_ref_filesystem.asp for more information on the file system object. It took me quite a bit of putzing to get relative file addressing to work, but I did - mostly through trial and error.
I also recommend this site in general for basic
ASP and VBScript stuff.
Hope this makes sense
jakyra