Using VBScript sending emails to outside recipients not working RRS feed

  • Question

  • I am trying to use vbscript to send a file to an email address outside my domain. But I keep getting the following message:

    "Error: The server rejected one or more recipient addressses. The server response was: 550.5.7.1 Unable to relay"

    If i use the same script and send it to an email address inside our domain it works fine. What am I doing wrong? Below is my code:

    Set objEmail = CreateObject("CDO.Message")

    objEmail.From = "xxxx@domain.com"
    objEmail.To = "yyyy@hotmail.com"
    objEmail.Subject = "Server down" 
    objEmail.Textbody = "Server1 is no longer accessible over the network."
    objEmail.AddAttachment "E:\TEST\TEST.CSV"

    objEmail.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
    objEmail.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEmail.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxx@domain.com"
    objEmail.Configuration.Fields.Item _ 
        ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"


    • Moved by Carl Cai Thursday, September 26, 2013 6:08 AM offtopic
    • Moved by Dave PatrickMVP Thursday, September 26, 2013 9:25 AM
    Wednesday, September 25, 2013 2:06 PM


All replies

  • Hi

    I think problem is not in your code but it seems problem with relay in your SMTP server.

    Nayan Paregi (MCTS)
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Thursday, September 26, 2013 4:47 AM
  • Hi,

    Thank you for visiting the MSDN forum. I’m afraid that it is not the correct forum about this issue, since this forum is to discuss Visual Basic and this issue is relate to VBScript.

    You can consider posting it in these links below to get more efficient responses.

    1. http://social.msdn.microsoft.com/Forums/en-US/scripting/threads

    2. If this is Visual Basic for Applications, and for Outlook, it should probably be asked in the Outlook for Developers forum.

    3. microsoft.public.windows.server.scripting:http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads

    Thanks for your understanding.


    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Edited by Carl Cai Thursday, September 26, 2013 6:07 AM
    Thursday, September 26, 2013 6:07 AM
  • Thanks I will post the question there. I did think it could be the SMTP relay server. 
    Thursday, September 26, 2013 3:50 PM
  • Just in case anyone was wondering found the answer:

    Here is the answer. I needed to create a Recieve Connector on our Exchange server for the server I was trying to send mail from. The below URL has all the steps.


    • Marked as answer by Natron61 Tuesday, October 1, 2013 7:16 PM
    Tuesday, October 1, 2013 7:16 PM