Hello,
The following script has worked fine for us until our ISP changed our outgoing mail server to one that requires authentication. Can someone please assist me in updating the following code so it will authenticate on the outgoing mail server?
Code:
Sub Send_Mail_Messages_With_SMTP()
On Error GoTo Error_Handler
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoNTLM = 2 'NTLM
Dim item As Integer
Dim attlist As String
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Dim strAttachment2
Dim stBody1 As String, stBody2 As String, stSubject As String
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.configuration")
Set Flds = iConf.Fields
'Set lfsFile1 = CreateObject("Scripting.FileSystemObject")
With Flds
.item("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2 'cdoSendUsingPort
.item("http://schemas.microsoft.com/cdo/con...smtpserverport") = 25
'Configuration for IX Webhosting without Authentication:
.item("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "mail.sthealthgroup.com"
'Server timeout set to 300 seconds due to current issues with SMTP connect delay with IX Webhosting as of 2/20/2008
.item("http://schemas.microsoft.com/cdo/con...nectiontimeout") = 300
.Update
End With
With iMsg
Set .Configuration = iConf
.To = Send_To_Email_Address
.cc = CC_Email_Address
.bcc = BCC_Email_Address
.from = Sent_From_Email_Address
.ReplyTo = "HMAH_CCR@sthealthgroup.com;" & Sent_From_Email_Address & ";" & CC_Email_Address
.Subject = Subject_Line
'.TextBody = EMailBodyText
.HTMLBody = HTMLBodyText
[Form_EMAIL_DISTRIB].txtSource_Location.SetFocus
For Counter = 1 To TempCounter
.AddAttachment [Form_EMAIL_DISTRIB].txtSource_Location.Text & CurrentHospital & Attachment_Name(Counter)
Next Counter
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
Exit Sub
Error_Handler:
MsgBox Err.Number & " " & Err.Description
Resume Next
End Sub