none
C# code : Exchange says OK but doesn't send email RRS feed

  • Question

  • Dear Exchange community,

    I need your help for the following issue :

    I execute some C# code below for asking Exchange 2007 to send some emails, i get some positive answer from Exchange, BUT, i never receive the email.

    Question : is there some missing configuration on my Exchange server, or some missing instruction in my C# code ?

    Log in Exchange side, which shows Exchange receives my request :

    C:\Program Files\Microsoft\Exchange Server\TransportRoles\Logs\MessageTracking :

    2014-04-24T09:30:15.878Z,::1,SRV.mydomain.loc,::1,srv,,,STOREDRIVER,RECEIVE,3,<35A53654FA57D046B63B71C213CFD5239ECF79127E@SRV.mydomain.loc>,smith@mycompany.com,,3329,1,,,HelloWorld,test2@mydomain.loc,test2@mydomain.loc,04I:

    Answer from Exchange :

    <ResponseMessage ResponseClass="Success">
    
    ...
    
    <Trace Tag="EwsRequestHttpHeaders" Tid="9" Time="2014-04-25 09:12:23Z">
    POST /ews/exchange.asmx HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    Accept: text/xml
    User-Agent: ExchangeServicesClient/14.03.0032.000
    Accept-Encoding: gzip,deflate
    
    <m:ResponseMessages>
      <m:CreateItemResponseMessage ResponseClass="Success">
        <m:ResponseCode>NoError</m:ResponseCode>
        <m:Items />
      </m:CreateItemResponseMessage>
    </m:ResponseMessages>

    C# code :
    static void Main(string[] args)
    {
               ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
       string log = "";
       exchange_service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
       exchange_service.TraceEnabled = true;
       exchange_service.TraceFlags = TraceFlags.All;
       exchange_service.Credentials = new WebCredentials(userName, userPassword, domain);
       exchange_service.Url = new Uri("https://" + exchangeServerAddr + "/ews/exchange.asmx");
    			
       if (null != exchange_service.ServerInfo)
       {
           Console.WriteLine("Exchange server: " + exchange_service.ServerInfo.VersionString);
           EmailMessage email = new EmailMessage(service);
                      email.ToRecipients.Add("smith@company.com");
           email.Subject = "HelloWorld";
           email.From = from;
           email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API.");
           email.Send();
       }
       Console.Read();
    }

    Regards

    Eric


    • Edited by Dumond Friday, April 25, 2014 10:03 AM
    Friday, April 25, 2014 9:43 AM

All replies

  • So, the answer is : the email sender must belonging to the same Exchange server than the receiver. Both emails must having the same suffixe.

    That's all.

    I thank you myself for my precious cooperation.

    Friday, April 25, 2014 6:15 PM