nikki85 Try using this and look for proper port numbers and authentication type.
Function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
Dim smtpServer, smtpPort, userLogin, userPassword
Dim authenticationType, useSSL, connectionTimeout
Dim schema, mConfig, mMessage
smtpServer = "SERVER NAME"
smtpPort = 465 'port number
userLogin = "USERNAME" ' e.g. "abc" if the address is abc@gmail.com
userPassword = "PASSWORD"
authenticationType = 1 ' cdoBasic
connectionTimeout = 30
useSSL = True
Err.Clear()
On Error Resume Next
schema = "http://schemas.microsoft.com/cdo/configuration/"
Set mConfig = Sys.OleObject("CDO.Configuration")
mConfig.Fields.Item(schema & "sendusing") = 2 ' cdoSendUsingPort
mConfig.Fields.Item(schema & "smtpserver") = smtpServer
mConfig.Fields.Item(schema & "smtpserverport") = smtpPort
mConfig.Fields.Item(schema & "sendusername") = userLogin
mConfig.Fields.Item(schema & "sendpassword") = userPassword
mConfig.Fields.Item(schema & "smtpauthenticate") = authenticationType
mConfig.Fields.Item(schema & "smtpusessl") = useSSL
mConfig.Fields.Item(schema & "smtpconnectiontimeout") = connectionTimeout
mConfig.Fields.Update()
Set mMessage = Sys.OleObject("CDO.Message")
Set mMessage.Configuration = mConfig
mMessage.From = mFrom
mMessage.To = mTo
mMessage.Subject = mSubject
mMessage.HTMLBody = mBody
If 0 < Len(mAttachment) Then
mMessage.AddAttachment(mAttachment)
End If
mMessage.Send()
If Err.Number > 0 Then
Call Log.Error("E-mail cannot be sent", Err.Description)
SendEMail = False
Err.Clear()
Else
Log.Message("Message to <" & mTo & "> was successfully sent")
SendEMail = True
End If
End Function
Also, do post the error if you see any in error log