The following function covers emailing from ASP:
<%
Function sendMail (strTo, strFrom, strSubject, strMessage)
strFormat = “<style>” & vbcrlf & “body{font-family:Arial, Helvetica, sans-serif;font-size:10pt;}” & vbcrlf & “</style>”
sch = “http://schemas.microsoft.com/cdo/configuration/“
Set cdoConfig = CreateObject(“CDO.Configuration”)
With cdoConfig.Fields
.Item(sch & “sendusing”) = 2 ‘ cdoSendUsingPort
.Item(sch & “smtpserver”) = “Enter your email server IP here“
.Item(sch & “smtpauthenticate”) = 1 ‘cdoBasic
.Item(sch & “sendusername”) = “Enter your mailbox user here e.g. mail (which maps to mail@islandearth.com – you don’t need the domain)”
.Item(sch & “sendpassword”) = “Enter your mailbox password here“
.update
End With
Set cdoMessage = CreateObject(“CDO.Message”)
On Error Resume Next
With cdoMessage
Set .Configuration = cdoConfig
.To = strTo
.From = strFrom
.Subject = strSubject
‘.TextBody = strMessage
.HTMLBody = strFormat & strMessage
.Send
End With
‘Response.Write strMessage
If err.Number <> 0 Then
SendMail = False
Response.Write err.Number
Else
SendMail = True
End If
Set cdoMessage = Nothing
Set cdoConfig = Nothing
End Function
%>
And here is an example calling this function:
x=sendMail (“reports@islandearth.com”, “Reports”, “A test report”, “Test email”)
This will send an email with ‘Test email’ as the body, ‘A test report’ as the subject line, ‘Reports’ as the from address, ‘reports@islandearth.com’ as the To address.
x is true if all ok, false if an error occurred.
Happy emailing!