Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to create a macro to send a test email using the examples on the forum. I created
function sendMailTest()
Dim objEmail
Const cdoSendUsingPort = 2 ' Send the message using SMTP
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Const SMTPServer = "mail.btinternet.com"
Const SMTPPort = 25 'Port number for SMTP
Const SMTPTimeout = 60 'Timeout for SMTP in seconds
'Sending mail
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")= cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")= SMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")= cdoBasic
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= SMTPPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")= False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")= SMTPTimeout
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") ="<my account name>"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="<my password>"
.Update
End With
objEmail.To = "<my accountname>"
objEmail.From = "<my accountname>"
objEmail.Subject = "test"
objEmail.TextBody = "test text"
objEmail.Send 'FAILS HERE
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
msgbox ("Test Mail Sent")
end function
I require authentication to send this which I have put in the code. The problem is that I get an error when sending.
The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
All the details appear correct but it does not work. Does anyone know what is wrong ? Also, in user preferences, I have set up the same email account using an AUTH LOGON authentication and this works fine. What I would really like is to be able to send an email using the details set up here rather than having to put user names and passwords in the code.
Any help is appreciated.
David
HI,
Did you manage to solve this?
/Daniel
' SMTP server details | |||
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 | |||
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your smtp server no" | |||
if len(vUser) > 0 then | |||
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 | |||
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Vikas" | |||
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = false | |||
else | |||
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0 | |||
end if | |||
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 | |||
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False | |||
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 | |||
.Update |
Dear David
Please check with SMTP server setting given below I am able to send the mails from qlikview server automatically.
Const SMTPServer = "mail.btinternet.com" here you need to put smtp server ip address.
Hi
I found the error, I had to change the smtpauthenticatemethod to cdoAnonymous instead of cdobasic.
/Daniel
Thanks everyone for your comments but none of it works. I originally had cdoAnonymous but this fails. I am baffled.