Hi Below codes work for sending email from contact@domain.com How am I going to display from name as "Jhon Smith" programatically? Where am i doing wrong? Please help me.

        Test.ExchangeWebServices.ExchangeServiceBinding esb = new Test.ExchangeWebServices.ExchangeServiceBinding();
        esb.Credentials = new NetworkCredential("contact", "pass", "domain");
        esb.Url = @"https://mail.domain.com/EWS/Exchange.asmx";

        // Specify the request version.
         esb.RequestServerVersionValue = new RequestServerVersion();
         esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;

        // Create the CreateItem request.
        CreateItemType createEmailRequest = new CreateItemType();

        // Specifiy how the e-mail will be handled.
        createEmailRequest.MessageDisposition = MessageDispositionType.SendAndSaveCopy;
        createEmailRequest.MessageDispositionSpecified = true;

        // Specify the location of sent items. 
        createEmailRequest.SavedItemFolderId = new TargetFolderIdType();
        DistinguishedFolderIdType sentitems = new DistinguishedFolderIdType();
        sentitems.Id = DistinguishedFolderIdNameType.sentitems;
        createEmailRequest.SavedItemFolderId.Item = sentitems;

        // Create the array of items.
        createEmailRequest.Items = new NonEmptyArrayOfAllItemsType();

        // Create a single e-mail message.
        MessageType message = new MessageType();
        message.Subject = "Daily Report";
        message.Body = new Test.ExchangeWebServices.BodyType();
        message.Body.BodyType1 = BodyTypeType.Text;
        message.Body.Value = "email body is here. " + System.DateTime.Now.ToLongTimeString();

        message.Sender = new SingleRecipientType();
        message.Sender.Item = new EmailAddressType();
        message.Sender.Item.EmailAddress = "contact@domain.com";
        message.Sender.Item.Name = "Jhon Smith";

        message.ReplyTo = new EmailAddressType[1];
        message.ReplyTo[0] = new EmailAddressType();
        message.ReplyTo[0].EmailAddress = "contact@domain.com";



       //message.From = new SingleRecipientType();
       //message.From.Item = new EmailAddressType();
       //message.From.Item.EmailAddress = "test@domain.com";

        //message.From.Item.EmailAddress = "benim";

        message.ToRecipients = new EmailAddressType[1];
        message.ToRecipients[0] = new EmailAddressType();
        message.ToRecipients[0].EmailAddress = "deneme@msn.com";
     //   message.ReplyTo = "Deneme@msn.com";
        message.Sensitivity = SensitivityChoicesType.Normal;

        // Add the message to the array of items to be created.
        createEmailRequest.Items.Items = new ItemType[1];
        createEmailRequest.Items.Items[0] = message;
        MessageBox.Show("Done!");
        //try
        //{
            // Send a CreateItem request and get the CreateItem 

// response. CreateItemResponseType createItemResponse = esb.CreateItem(createEmailRequest); ArrayOfResponseMessagesType responses = createItemResponse.ResponseMessages; Test.ExchangeWebServices.ResponseMessageType[] responseMessages = responses.Items;

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown