none
Sending Mails thru Microsoft Office 365

    Question

  • Hello,

    Our application is running in visual foxpro 6 and recently we have switched our mail server to Microsoft Office 365. Our foxpro application send out mails, which is giving the below error after switching to microsoft Office 365.

    Error: OLE IDispatch exception code 0 from ?. The server rejected the sender address. The server response was: 530 5.7.1 Client was not authenticated.

    The below is the code which I used to send out mails.

    Local lcSchema, loConfig, loMsg, loAtt, lnCountAttachments,cTo
    lcSchema = "http://schemas.microsoft.com/cdo/configuration/"
    loConfig = CREATEOBJECT("CDO.Configuration")

    With loConfig.FIELDS
        .ITEM(lcSchema + "smtpserver") = "pod51011.outlook.com" && host of smtp server
        .ITEM(lcSchema + "smtpserverport") = 587
        .ITEM(lcSchema + "sendusing") = 2 
        .ITEM(lcSchema + "smtpconnectiontimeout") = 30
        .ITEM(lcSchema + "smtpusessl") = .F.
        .ITEM(lcSchema + "smtpauthenticate") = 1
            .ITEM(lcSchema + "sendusername") = "Administrator@ourmailserver.com"
            .ITEM(lcSchema + "sendpassword") = "mypassword"    
        .UPDATE
    Endwith    


    loMsg = CREATEOBJECT("CDO.Message")
    loMsg.Configuration = loConfig

    With loMsg

        .FROM = "Administrator@ourmailserver.com"    
        .TO = "myname@gmail.com"
        .Subject = "Some Subject"    
        .TextBody = "Some text"    
        .SEND()
        
        Messagebox("Message Sent")
    Endwith
    Release loConfig, loMsg

    Please Let me know what the issue in this.

    Thanks in advance.

    Wednesday, February 15, 2012 12:27 PM

Answers

  • HI,

    welcome to the MSDN forum.

    your issue is a general issue, and I'm not sure where the issue is. but if you wants to send an E-mail with an attachment, try using this link: http://support.microsoft.com/default.aspx?scid=KB;EN-US;181899 

    Here is also have some similar issue with yours, please pay attention the version of FoxPro:

    Error Sending a Fax using FAXCOMEX (OLE IDIspatch exception Code 0 from FaxComEx.FaxDocument 1: Operation failed) : http://qa.social.msdn.microsoft.com/Forums/en-US/visualfoxprogeneral/thread/a33ac502-a159-44c6-8a7f-a053572c09bf

    OLE IDispatch exception code 0 from ?:?..:http://www.tek-tips.com/viewthread.cfm?qid=1020583 

    hope it helps.


    No code, No fact.

    Thursday, February 16, 2012 6:15 AM
  • CDO mail is not supported in Office 365. More info: http://community.office365.com/en-us/f/159/t/3250.aspx and http://letsexchange.blogspot.com/2011/07/office-365-limitations.html

    You may try to use SMTP Relay: http://blogs.technet.com/b/msonline/archive/2009/09/02/using-smtp-relay-with-exchange-online.aspx

    The appropriate code could look like this example (untested, converted from VB):

    #DEFINE cdoSendUsingPort 2
    #DEFINE cdoBasic 1
    #DEFINE cdoNTLM 2
    iMsg = CreateObject("CDO.Message")
    iConf = CreateObject("CDO.Configuration")
    Flds = iConf.Fields
    With Flds
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Smtp.mail.microsoftonline.com"
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username@domain.com"
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    	.Update
    EndWith
    With iMsg
    	.Configuration = iConf
    	.From = "youruser@domain.com"
    	.To = "targetuser@domain.com"
    	.Subject = "This is a test message in HTML format"
    	.HTMLBody = "Place HTML body here"
    	.Send
    EndWith
    iMsg = Null
    iConf = Null
    Flds = Null
    
    Saturday, February 25, 2012 9:45 PM
    Moderator
  • it works with Office 365 and CDO, but you have tu use Port 25 instead of 587:

    SmtpMail.SmtpServer = pod0000.outlook.com; //your smtp server
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusing”,”2″);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”, “1″);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername”, myusername@email.com);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword”, mypassword);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”, 25);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpusessl”,”true”);
    • Proposed as answer by hoeschi Wednesday, February 29, 2012 11:40 PM
    • Marked as answer by Mark Liu-lxfModerator Friday, March 02, 2012 6:30 AM
    Wednesday, February 29, 2012 11:39 PM

All replies

  • HI,

    welcome to the MSDN forum.

    your issue is a general issue, and I'm not sure where the issue is. but if you wants to send an E-mail with an attachment, try using this link: http://support.microsoft.com/default.aspx?scid=KB;EN-US;181899 

    Here is also have some similar issue with yours, please pay attention the version of FoxPro:

    Error Sending a Fax using FAXCOMEX (OLE IDIspatch exception Code 0 from FaxComEx.FaxDocument 1: Operation failed) : http://qa.social.msdn.microsoft.com/Forums/en-US/visualfoxprogeneral/thread/a33ac502-a159-44c6-8a7f-a053572c09bf

    OLE IDispatch exception code 0 from ?:?..:http://www.tek-tips.com/viewthread.cfm?qid=1020583 

    hope it helps.


    No code, No fact.

    Thursday, February 16, 2012 6:15 AM
  • CDO mail is not supported in Office 365. More info: http://community.office365.com/en-us/f/159/t/3250.aspx and http://letsexchange.blogspot.com/2011/07/office-365-limitations.html

    You may try to use SMTP Relay: http://blogs.technet.com/b/msonline/archive/2009/09/02/using-smtp-relay-with-exchange-online.aspx

    The appropriate code could look like this example (untested, converted from VB):

    #DEFINE cdoSendUsingPort 2
    #DEFINE cdoBasic 1
    #DEFINE cdoNTLM 2
    iMsg = CreateObject("CDO.Message")
    iConf = CreateObject("CDO.Configuration")
    Flds = iConf.Fields
    With Flds
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Smtp.mail.microsoftonline.com"
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username@domain.com"
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    	.Update
    EndWith
    With iMsg
    	.Configuration = iConf
    	.From = "youruser@domain.com"
    	.To = "targetuser@domain.com"
    	.Subject = "This is a test message in HTML format"
    	.HTMLBody = "Place HTML body here"
    	.Send
    EndWith
    iMsg = Null
    iConf = Null
    Flds = Null
    
    Saturday, February 25, 2012 9:45 PM
    Moderator
  • it works with Office 365 and CDO, but you have tu use Port 25 instead of 587:

    SmtpMail.SmtpServer = pod0000.outlook.com; //your smtp server
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusing”,”2″);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”, “1″);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername”, myusername@email.com);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword”, mypassword);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”, 25);
    webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpusessl”,”true”);
    • Proposed as answer by hoeschi Wednesday, February 29, 2012 11:40 PM
    • Marked as answer by Mark Liu-lxfModerator Friday, March 02, 2012 6:30 AM
    Wednesday, February 29, 2012 11:39 PM