I have a legacy VB6 app. All was fine as we had our own Exchange server but we have since gone to Office 365.
Any ideas? Thanks.
Swi
Code:
Sub SendEMail(strSubject As String, strRecipient As String, strCC As String, strBCC As String, strSender As String, strBodyText As String, strAttachment As String)
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Dim i As Integer
'On Error Resume Next
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1
Set Flds = iConf.Fields
With Flds
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpusessl")[/URL] = False
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL] = 1
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] = "XXXXX"
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] = "XXXXX"
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "smtp.office365.com"
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60
.Update
End With
Dim iBP
With iMsg
Set .Configuration = iConf
.To = strRecipient
.From = strSender
.CC = strCC
.BCC = strBCC
.Subject = strSubject
.HTMLBody = strBodyText
If strAttachment <> "" And FlagMarker <> "Daily" Then Set iBP = iMsg.AddAttachment(strAttachment)
.Send
End With
Set iBP = Nothing
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Sub
Any ideas? Thanks.
Swi