none
CDOSYS and Office365 Exchange Online RRS feed

  • Question

  • Hello,


    I have been working previously on an exchange 2003 and used CDO objects to send mails through the exchange 2003.

    Since I have migrated to Office 365 Exchange online, I have found issues in using the CDO objects to send mail.

    Are there any configurations that are working for the current time?


    Thank you for your reply

    • Moved by SathyanarrayananS Friday, November 20, 2015 12:18 PM Moving to Microsoft Office
    Friday, November 20, 2015 12:06 PM

Answers

  • Hi Omriato,

    >> Since I have migrated to Office 365 Exchange online, I have found issues in using the CDO objects to send mail.

    It would be helpful if you could share us your code to use CDO objects.

    I made a test with Office 365 account, and it worked correctly, you could refer the code below for a simple code.

    Option Compare Database
    
    Sub SendMail()
    
    Dim oCdo As Object
    Dim oConf As Object
    Dim Flds As Object
    Dim strHtml As String  'variable contenu du corps de message
    Dim destinataire As String
    Dim attachment As String
    Dim DerLig
    
    ' Définit le contenu du message au format HTML
    strHtml = "<HTML><HEAD><BODY>"
    strHtml = strHtml & "<center><b> Ceci est un message de test au format <i><Font Color=#ff0000 > HTML. </Font></i></b></center>"
    strHtml = strHtml & "</br>Veuillez prendre connaissance de la piece jointe."
    strHtml = strHtml & "</BODY></HEAD></HTML>"
    
    
    Set oCdo = CreateObject("cdo.Message")
    'Set oConf = CreateObject("cdo.configuration")
    'Set Flds = oConf.Fields
    
    With oCdo.configuration.Fields
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com" 'adresse du serveur smtp
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  'tester 25, 465 ou 587
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True  'Utilise une connection SSL (True or False)
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 40
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 '0 : pas d'authentification, 1 : authentification basique
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your Office365 account " 'identifiant de messagerie
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your password" 'mot de passe de messagerie
        .Update
    End With
    
    With oCdo
        .Subject = "Votre facture"                                            ' objet du message
        .From = "your office 365 account"                                                   ' adresse de l'expéditeur
        .To = "target account"                                                    ' adresse du destinataire
        .BCC = ""                                                             ' en copie cachée pour conserver trace
        .HtmlBody = strHtml                                                   ' corps du message HTML
        '.AddAttachment (attachement)                                         ' ajout de pièce jointe
        '.MDNrequested = True
        .Send
    
    End With
    
    Set oCdo = Nothing
    
    End Sub
    

    For more information about sending email using Office 365, you could refer the link below:

    # How to set up a multifunction device or application to send email using Office 365
    https://technet.microsoft.com/en-us/library/dn554323.aspx?f=255&MSPPError=-2147217396

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, November 23, 2015 7:38 AM

All replies

  • Hello,

    In which way is this related to T-SQL, the Topic of this forum?


    Olaf Helper

    [ Blog] [ Xing] [ MVP]


    Friday, November 20, 2015 12:18 PM
  • Hi Omriato,

    >> Since I have migrated to Office 365 Exchange online, I have found issues in using the CDO objects to send mail.

    It would be helpful if you could share us your code to use CDO objects.

    I made a test with Office 365 account, and it worked correctly, you could refer the code below for a simple code.

    Option Compare Database
    
    Sub SendMail()
    
    Dim oCdo As Object
    Dim oConf As Object
    Dim Flds As Object
    Dim strHtml As String  'variable contenu du corps de message
    Dim destinataire As String
    Dim attachment As String
    Dim DerLig
    
    ' Définit le contenu du message au format HTML
    strHtml = "<HTML><HEAD><BODY>"
    strHtml = strHtml & "<center><b> Ceci est un message de test au format <i><Font Color=#ff0000 > HTML. </Font></i></b></center>"
    strHtml = strHtml & "</br>Veuillez prendre connaissance de la piece jointe."
    strHtml = strHtml & "</BODY></HEAD></HTML>"
    
    
    Set oCdo = CreateObject("cdo.Message")
    'Set oConf = CreateObject("cdo.configuration")
    'Set Flds = oConf.Fields
    
    With oCdo.configuration.Fields
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com" 'adresse du serveur smtp
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  'tester 25, 465 ou 587
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True  'Utilise une connection SSL (True or False)
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 40
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 '0 : pas d'authentification, 1 : authentification basique
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your Office365 account " 'identifiant de messagerie
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your password" 'mot de passe de messagerie
        .Update
    End With
    
    With oCdo
        .Subject = "Votre facture"                                            ' objet du message
        .From = "your office 365 account"                                                   ' adresse de l'expéditeur
        .To = "target account"                                                    ' adresse du destinataire
        .BCC = ""                                                             ' en copie cachée pour conserver trace
        .HtmlBody = strHtml                                                   ' corps du message HTML
        '.AddAttachment (attachement)                                         ' ajout de pièce jointe
        '.MDNrequested = True
        .Send
    
    End With
    
    Set oCdo = Nothing
    
    End Sub
    

    For more information about sending email using Office 365, you could refer the link below:

    # How to set up a multifunction device or application to send email using Office 365
    https://technet.microsoft.com/en-us/library/dn554323.aspx?f=255&MSPPError=-2147217396

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, November 23, 2015 7:38 AM