Example of a Function to Send Emails With CDO In ASP
Asp / / July 04, 2021
I made this function to constantly send emails from the forms of my pages in ASP, so I only have to create a file and include it to send emails in ASP.
Send Mail function (fname sender, femail sender, fmessage, femailpara, fasunto, fadjoint)
ON ERROR RESUME NEXT
'Send a text mail using authentication on an SMTP server
Const cdoSendUsingPickup = 1 'Send message using SMTP local directory pickup service
Const cdoSendUsingPort = 2 'Send using network, SMTP over network
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'Authenticate basic (plain text)
Const cdoNTLM = 2 'NTLM
Set objMessage = CreateObject ("CDO.Message")
objMessage. Subject = issue
objMessage. From = f sendername & ""
objMessage. To = femailpara
objMessage. Bcc = fbcc
objMessage. TextBody = fmessage
IF fadjoint <> "" THEN
objMessage. AddAttachment fadjoint
END IF
'== Here you configure the SMTP server.
objMessage. Configuration. Fields. Item _
("https://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage. Configuration. Fields. Item _
("
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage. Configuration. Fields. Item _
("https://schemas.microsoft.com/cdo/configuration/authenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage. Configuration. Fields. Item _
("https://schemas.microsoft.com/cdo/configuration/sendusername") =" USER "
'Your password on the SMTP server
objMessage. Configuration. Fields. Item _
("https://schemas.microsoft.com/cdo/configuration/sendpassword") =" PASSWORD "
'Server port (typically 25)
objMessage. Configuration. Fields. Item _
("https://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage. Configuration. Fields. Item _
("https://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'TIMEOUT in seconds, the maximum time that CDO will try to establish a connection with the SMTP
objMessage. Configuration. Fields. Item _
("https://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage. Configuration. Fields. Update
'== Finish SMTP configuration ==
objMessage. Send
SendEmail = femailpara & ","
End Function
%>