Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO and Office 365

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,963
US
I have a legacy VB6 app. All was fine as we had our own Exchange server but we have since gone to Office 365.

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top