KB-28661: Sending e-mails without a driver using IIS and CDO.

Question:

On an application based in CDO-Collaboration Data Objects (tool developed by Microsoft to make it easier sending messages in applications)-, the IIS – Internet Information Services – is used to send e-mails without using the SendMail driver.

However, the messages are not being sent, and an error message is returned. How can I fix this problem?

Solution:

This can happen because the server being used needs authentication. So, to fix the problem, you must increment the following lines in the script that sends the e-mail:
Sub CommandButton1_Click() 
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Email's title"
objMessage.Sender = "sender@server.com"
objMessage.To = "recipient@server.com"
objMessage.TextBody = "Email's text body"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "send@server.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "user password"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
objMessage.Send
MsgBox "The e-mail was successfully sent!"
End Sub
Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 5 / 5. Count: 1

Leave a Reply

Your email address will not be published.Required fields are marked *