<% sub ExecuteMail(mailtype,My_from,my_fromaddress,my_to,my_toaddress,my_subject,body,emailformat,Orderattachments, Orderattachmentcount) '***************************************************************************** ' Version 4.00 Multiple Attachments ' CDONTS, ASPMAIL, JMAIL, ASPEMAIL,OCXMAIL, CDOSYS ' January 18, 2002 '***************************************************************************** dim mailer dim mailerror dim htmlformat dim i 'my_system=getconfig("xemailsystem") htmlformat=ucase(emailformat) on error resume next If getconfig("xdebug")="Yes" then Debugwrite "to=" & my_to & "(" & my_toaddress &") from=" & my_from &"("& my_fromaddress &")" debugwrite "attachments=" & orderattachmentcount debugwrite body end if If ucase(mailtype)="CDONTS" Then Set Mailer = Server.CreateObject("CDONTS.NewMail") if err.number<> 0 then mailerror=langmailerror & " " & mailtype HandleMailError mailerror exit sub end if Mailer.To = my_toaddress Mailer.From = my_from & " <" & my_fromaddress & ">" Mailer.Subject = my_subject Mailer.Body = body If htmlformat="HTML" then Mailer.BodyFormat = 0 Mailer.MailFormat = 0 end if If Orderattachmentcount>0 then for i = 0 to orderattachmentcount-1 Mailer.AttachFile orderattachments(i) If getconfig("xdebug")="Yes" then Debugwrite "adding " & orderattachments(i) end if next Orderattachmentcount=0 end if Mailer.Send set mailer=nothing exit sub end if if ucase(mailtype)="ASPMAIL" then Set Mailer = Server.CreateObject("SMTPsvg.Mailer") ' response.write "mail error " & err.number if err.number<> 0 then mailerror=langmailerror & " " & mailtype HandleMailError mailerror exit sub end if Mailer.AddRecipient my_to, my_toaddress Mailer.RemoteHost = my_system Mailer.FromName = my_from Mailer.FromAddress = my_fromAddress Mailer.Subject = my_subject Mailer.BodyText=body If htmlformat="HTML" then Mailer.ContentType = "text/html" end if If Orderattachmentcount>0 then for i = 0 to orderattachmentcount-1 Mailer.AddAttachment orderattachments(i) next end if If Mailer.SendMail then set Mailer=nothing exit sub else mailerror=langmailerror & " " & my_toaddress mailerror=mailerror & "
" & mailer.response HandleMailError mailerror Set mailer=nothing exit sub end if end if If ucase(Mailtype) = "JMAIL" Then Set Mailer = Server.CreateObject("JMail.SMTPMail") if err.number<> 0 then mailerror=langmailerror & " " & mailtype HandleMailError mailerror exit sub end if Mailer.ServerAddress = my_system Mailer.Sender = my_fromAddress Mailer.SenderName = my_from Mailer.AddRecipient my_toaddress Mailer.Subject = my_subject If htmlformat="HTML" then Mailer.ContentType = "text/html" end if Mailer.Body = body If Orderattachmentcount>0 then for i = 0 to orderattachmentcount-1 Mailer.AddAttachment orderattachments(i) next end if If Mailer.execute then set Mailer=nothing exit sub else mailerror=langmailerror & " " & my_toaddress HandleMailError mailerror set mailer=nothing exit sub end if end if If ucase(Mailtype) = "ASPEMAIL" Then Set Mailer = Server.CreateObject("Persits.MailSender") if err.number<> 0 then exit sub end if Mailer.Host = my_system Mailer.From = my_fromAddress Mailer.FromName = my_from Mailer.AddAddress my_toaddress, my_to Mailer.Subject = my_subject If htmlformat="HTML" then Mailer.IsHTML = TRUE end if If Orderattachmentcount>0 then for i = 0 to orderattachmentcount-1 Mailer.AddAttachment orderattachments(i) next end if Mailer.Body = body If Mailer.Send then set Mailer=nothing exit sub else mailerror=langmailerror & " " & my_toaddress HandleMailError mailerror set mailer=nothing exit sub end if end if If ucase(Mailtype) = "OCXMAIL" Then Set mailer = Server.CreateObject("ASPMAIL.ASPMailCtrl.1") If htmlformat="HTML" then dim result result=Mailer.XHeader ("Content-Type", "text/html") end if mailerror = mailer.SendMail(my_system, my_toaddress, my_fromaddress, my_subject, body) If "" = mailerror Then Set mailer=nothing exit sub Else mailerror=langmailerror & " " & my_toaddress & VbCR & mailerror HandleMailError mailerror set mailer=nothing End If exit sub End IF If ucase(mailtype)="CDOSYS" then Dim iConf Dim Flds ' Send by connecting to port 2 of the SMTP server. Const cdoSendUsingPort = 2 set Mailer = CreateObject("CDO.Message") set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields ' Set the CDOSYS configuration fields to use port 25 on the SMTP server. With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =cdoSendUsingPort 'ToDo: Enter name or IP address of remote SMTP server. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =my_system .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 .Update End With ' Apply the settings to the message. With Mailer Set .Configuration = iConf .To = my_toaddress 'ToDo: Enter a valid email address. .From = my_from & " <" & my_fromaddress & ">" 'ToDo: Enter a valid email address. .Subject = my_subject If Orderattachmentcount>0 then for i = 0 to orderattachmentcount-1 .AddAttachment orderattachments(i) next end if If htmlformat="HTML" then .HTMLBody = body Else .TextBody = body End if .Send End With Set Mailer=Nothing Set iConf=Nothing exit sub end if mailerror=langmailerror & " " & mailtype HandleMailError mailerror end sub Sub HandleMailerror (errormsg) SetSess "mailerror",errormsg If getconfig("xDebug")="Yes" then debugwrite errormsg end if end sub %>