Send email (c#) using ews and set custom display name (from)

How to connect to exchange service via exchange web services send a mail and the display name is custom ?
With this code, just connect to exchange server (ews) and send a mail.
How to change my code ?
private void t() {
const string subjectBody = "test email ";
const string username = "username";
const string password = "password";
const string domain = "domain";
const string ewsURL = "http://exchangesrv/ews/exchange.asmx";
unews.ExchangeServiceBinding esb = new unews.ExchangeServiceBinding();
esb.Credentials = new System.Net.NetworkCredential( username, password, domain );
esb.Url = ewsURL;
unews.CreateItemType newItem = new unews.CreateItemType();
newItem.MessageDisposition = unews.MessageDispositionType.SendAndSaveCopy;
newItem.MessageDispositionSpecified = true;
unews.MessageType msg = new unews.MessageType();
msg.Subject = subjectBody;
msg.Body = new unews.BodyType();
msg.Body.BodyType1 = unews.BodyTypeType.Text;
msg.Body.Value = subjectBody;
msg.ToRecipients = new unews.EmailAddressType[1];
msg.ToRecipients[0] = new unews.EmailAddressType();
msg.ToRecipients[0].EmailAddress = "[email protected]";
newItem.Items = new unews.NonEmptyArrayOfAllItemsType();
newItem.Items.Items = new unews.ItemType[1];
newItem.Items.Items[0] = msg;
try {
unews.CreateItemResponseType createItemResponse = esb.CreateItem( newItem );
if (createItemResponse.ResponseMessages.Items[0].ResponseClass == unews.ResponseClassType.Error) {
throw new Exception( createItemResponse.ResponseMessages.Items[0].MessageText );
else {
Console.WriteLine( "Item was created" );
catch (Exception ex) {
Console.WriteLine( ex.ToString() );
With this code, can connect to a exchange server (smtp) and send a mail, with a custom display name.
System.Net.Mail.SmtpClient smtpc = new System.Net.Mail.SmtpClient( "exchangesrv" );
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage( "CustomDisplayName <[email protected]>", "[email protected]", "test email", "test email" );
smtpc.Credentials = new System.Net.NetworkCredential( "username", "password", "domain" );
smtpc.Send( mm );

That won't work the way you want it in EWS, like when you send via Outlook or OWA when you send a messages via EWS it's submitted via the Exchange store so the Sender Address will be resolved back to the default Reply address for whatever account your trying
to send as. If you need some sort of custom display name I would suggest you stick to SMTP or possible create a Transport Agent that would rewrite the address before its sent externally.
Cheers
Glen

Similar Messages

  • Create appointment using EWS and set BusyType with XML

    Hi guys,
    I have Exchange 2010 and am trying to create a calendar appointment using EWS with XML.  Everything works fine, but the "BusyType" option doesn't work.  I want the appointment to show in the calendar as "Free", but instead it
    shows as "Busy".  Here is what I have for the XML:
    <?xml version="1.0" encoding="utf-16"?>
    <CreateItemType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SendMeetingInvitations="SendToNone">
    <SavedItemFolderId xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
    <DistinguishedFolderId Id="calendar" xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
    <Mailbox>
    <EmailAddress>{ItemProperty:OTManager_x0020_Display_x0020_Name}</EmailAddress>
    <MailboxType>Mailbox</MailboxType>
    </Mailbox>
    </DistinguishedFolderId>
    </SavedItemFolderId>
    <Items xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
    <CalendarItem xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
    <ItemClass>IPM.Appointment</ItemClass>
    <Subject>Other Leave for {Common:InitiatorsDisplayName}</Subject>
    <Body BodyType="Text">Leave request</Body>
    <Location>
    </Location>
    <Importance>Normal</Importance>
    <Start>{ItemProperty:OTFrom}</Start>
    <End>{ItemProperty:OTTo}</End>
    <BusyType>Free</BusyType>
    </CalendarItem>
    </Items>
    </CreateItemType>
    I've also tried using "LegacyFreeBusyStatus" which also didn't work.  Can someone tell me how to modify my XML so that the appointment shows as "Free"?  The actual XML was generated using a workflow tool called "Nintex
    Workflow 2010", and I simply added the BusyType option to it.  I'm not sure if that makes a difference or not.  Thanks in advance!

    BusyType is not an element of the CalendarItem type it belongs to the CalendarEvent type which is part of the GetUserAvailability operation. There is a full list of CalendarItem elements on
    http://msdn.microsoft.com/en-us/library/office/aa564765(v=exchg.150).aspx (note the order of the elements is critical). You should be using the LegacyFreeBusyStatus eg the following works okay for me
    <m:Items>
    <t:CalendarItem>
    <t:Subject>tta</t:Subject>
    <t:Start>2014-02-04T12:53:33.970+11:00</t:Start>
    <t:End>2014-02-04T13:53:33.972+11:00</t:End>
    <t:LegacyFreeBusyStatus>Free</t:LegacyFreeBusyStatus>
    </t:CalendarItem>
    </m:Items>
    Cheers
    Glen

  • How to get and set custom tag attributes

    How do i get and set custom tag attributes from a jsp page?

    Not sure if this is what your looking for, but....
    example...
    < taglibprefix:testtag attribute1="x" attribute2="y">
    ...of course, the attributes have to be defined in your taglib (.tld) file

  • After installing the new Yosemite OS on my iMac I can no longer send email. I can receive email, but not send. I use gmail and can send email on the gmail (google) site, but not on "mail" on my iMac. Any others with this problem? What should we do?

    After installing the new Yosemite OS on my iMac I can no longer send email. I can receive email, but not send. I use gmail and can send email on the gmail (google) site, but not on "mail" on my iMac. Any others with this problem? What should we do?

    My gmail, which is correctly configured for Mail with gmail SMTP and Google IMAP, works for awhile on Mail, which I leave open while working on other applications. But several times a day I get msg from Google: "We recently blocked a sign-in attempt to your Google Account" . . . and requiring me to verify my account details, re-enter passwords, confirm security settings (or change them from "disable" to "enable less secure methods" and so on). In Mail I also have tried "taking all accounts online", and re-entering my gmail password inside Mail account settings. These steps successfully re-set comms between gmail and Mail ... for awhile, then it happens again. Enough occurrences over a work day that I just quit Mail and revert to accessing gmail directly. Apple Care advisor and an Apple knowledge base article say that Apple can't deal with this, as gmail is third-party app, and they refer me to gmail, and so far I've found nothing helpful there.
    From today I also have several instances of a window saying "Mail has unexpectedly closed" and asking me to Re-open it.
    I also use Yahoo mail, which stops working with Mac Mail at the same time as gmail, but I do not receive notices to re-verify from Yahoo.
    I recently upgraded from Mavericks to Yosemite. The Mail problem happened occasionally with Mavericks but is far more frequent with Yosemite.

  • I keep getting Alarm popups saying that it cannot send msg using the server null. I think I have disabled email (I use Gmail) and the calendar however I still get these popups and I can't close them?

    I keep getting Alarm popups saying that it cannot send msg using the server null.
    I think I have disabled email (I use Gmail) and the calendar however I still get these popups and I can't close them?
    How can I disable the Alarm popups?
    Thanks
    Brian

    OS X Mail: Troubleshooting sending and receiving email messages - Apple Support
    Google Mail recently implemented additional security measures "for your protection" of course. The manifestation of that may be the requirement to create a unique, "application-specific" password for each one of the various Google services you may use. That requirement probably includes Google Mail. So if the above Apple Support document doesn't resolve the problem, research Google's application-specific password requirements, and how to configure Mail to use it.
    I asked the Hosts to edit or obscure the email address in your post.

  • I am unable to see any POP3 or IMAP tab when I set up an account in my iphone 4S. Hence by default all my email accounts become IMAP and the messages are deleted from the server when I delete them from the iphone.

    I am unable to see any POP3 or IMAP tab when I set up an account in my iphone 4S. Hence by default all my email accounts become IMAP and the messages are deleted from the server when I delete them from the iphone.

    ok sorry everyone but i solved it myself but the solution is so nuts i've posted it here to help others who have the same problem.
    to setup a comcast imap account on your iphone:
    go to mail, contacts, etc in settings
    under accts, select add account
    select "other"
    new screen, choose "add mail account"
    now on the new acct screen you must enter your name, email address and password for your GMAIL acct ! (yes i said your gmail acct !, or some other acct with a NON comcast address).
    hit next
    then the acct verifies
    when verified a screen will open with all the acct settings for this acct AND @ the top of the screen are the 2 buttons > imap or POP
    select imap and THEN CHANGE ALL THE ACCOUNT information to the comcast account !
    then hit next and the account will take a couple minutes to verify but it will verify and now you have a comcast imap acct set up on your iphone.  The problem must be that when the iphone sends the initial verify acct info to comcast (if you enter that information first) the comcast server is simply not setup yet to signal the iphone that there is an imap option.

  • Sending udp packets using java and receiving it using c

    hi,
    Is it possible to send udp packets using java and receive the same using c??????? if yes.... plz help immediately.

    The biggest issue is data format. The JVM is big endian, with 16-bit characters. The machine running 'C' could be almost anything. A (signed!) byte array is probably the easiest unit of exchange.
    The Java program has its own techniques for storing/retrieving data to/from the byte array - and the C program has its own techniques. ASCII Strings are often the easiest to exchange - just convert the java String objects to byte array and send them.
    apaliwal1 has already given the UDP calls to send/receive the data.

  • I am having problems sending emails when using apps. I dont receive any emails when I try to send documents such as pdf or pictures. I tried sending it to my other email account but I don't get any email. What is wrong?

    I am having problems sending emails when using apps. I dont receive any emails when I try to send documents such as pdf or pictures. I tried sending it to my other email account but I don't get any email. What is wrong?

    System Preferences > Network > your-connection-medium > (Assist me) > ( Diagnostics )
    This sometimes provides additional helpful information, sometimes not so much.

  • Send email without using sender id

    Hi all,
    Is it possible to send email without using sender id?
    Thanks in advance

    nvv wrote:
    I m not asking this for spam. Actualy I m developing software that sends mail to many contacts. If i use sender address then they can use others like gmail, yahoo, or something like that instead.Sounds like spam software to me.

  • Using CSS and Javascript to display a div with flash in it, mozilla reloads the flash file!

    I am using CSS and Javascript to display a div with an
    embedded flash object in it. Mozilla Firefox reloads the flash file
    when the div is displayed! (I dont want this to happen, as it's
    unexpected functionality, my expectation would be that the flash
    file would not change it's state at all, and would remain in
    whatever state it was left in.)
    I was wondering if anyone has come across this issue and is
    there something I can do to prevent this from occurring?
    To be more specific, I have a single HTML page with 8 flash
    files embedded in it (yeah I know, it's a bit much). I am then
    using CSS and Javascript to display (via a numbered link (with an
    id)) an equivalent numbered div tag containing the flash file.
    Mozilla Firefox reloads the flash object that is in the div.
    Internet Explorer will not do this and will instead, load the flash
    object only upon initial view of the flash object. All subsequent
    links (in IE) will NOT reload the flash object on the page. I'm
    guessing this is some kind of difference in the flash player as an
    Active X object and the plugin, or is it just IE being clever? Or
    am I way off?
    Anyway, here is the code...

    I am using CSS and Javascript to display a div with an
    embedded flash object in it. Mozilla Firefox reloads the flash file
    when the div is displayed! (I dont want this to happen, as it's
    unexpected functionality, my expectation would be that the flash
    file would not change it's state at all, and would remain in
    whatever state it was left in.)
    I was wondering if anyone has come across this issue and is
    there something I can do to prevent this from occurring?
    To be more specific, I have a single HTML page with 8 flash
    files embedded in it (yeah I know, it's a bit much). I am then
    using CSS and Javascript to display (via a numbered link (with an
    id)) an equivalent numbered div tag containing the flash file.
    Mozilla Firefox reloads the flash object that is in the div.
    Internet Explorer will not do this and will instead, load the flash
    object only upon initial view of the flash object. All subsequent
    links (in IE) will NOT reload the flash object on the page. I'm
    guessing this is some kind of difference in the flash player as an
    Active X object and the plugin, or is it just IE being clever? Or
    am I way off?
    Anyway, here is the code...

  • I purchased a used iphone4 and the phone displays the previous owners apple id and prompts me for the previous owners password. how do i get rid of his info....and install my own apple id number?

    I purchased a used iphone4 and the phone displays the previous owners apple id and prompts me for the previous owners password. how do i get rid of his info....and install my own apple id number?

    Login to the app store with YOUR ID. You can't use the app store without an Apple ID. If there are apps on the phone that were purchased with the original owners ID, you do NOT own them. The owner had no legal right to give them to you and they are permanently tied to the ID that was used to purchase them.
    ...i was also allowed to purchase an apple network id for this phone...
    I have absolutely NO IDEA what you mean by that. You can not "purchase an apple network id".

  • Setting the display name in a message

    Hello for the following code:
    String from = "[email protected]";
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    I'd like to set the display name, i.e.
    "A Message From Foo"
    However I did not see a msg.setDisplayName() method... is there any way to do this?
    As a working example, amazon sends an email with a return address of [email protected], but the display name is 'Amazon Payments' which looks a lot nicer for the customer. I'd like to do the same.
    Thanks

    Solution is:
    new InternetAddress(email_address, display_name);

  • Presentation Layer - Custom Display Name

    We use Oracle Datamarts as Data Source thus in our Repository a lot of information is just routed through. Of course we configured the joins in the physical layer and added some hierarchies, joins and calculated measures to the business model.
    The question is now where to set the right column names which the end users will see (translation from technical column names to business column names). Normally I read that the naming should be done in the business model and then can be copied to the presentation model.
    Is there any reason why not to leave alle the technical column names through to the presentation model and just to do the naming with the Custom Display Names? This had the advantage that we could rename the column display names and the reports never had to be modified.
    Thank you for your thoughts and input

    The main reason could be this:
    If the attribute has been used in multiple subject areas, there is no need to go each subject areas and rename them, instead a one time rename in Business Modeling layer will do the work. Eg. Suppose there is a common dimension, say, Supplier/Customer/Time which are used in multiple subject areas. Renaming in Business modeling layer will be easier than going to each subject areas and rename them in presentation.
    Hope this helps..
    Thanks,
    Anilesh

  • We have an itunes account on our desktop and my kids have it on their ipod and iphone. I went in and changed our user name from my old e-mail address which is no longer accessible to my new one and now either of my kids can access the itunes store..

    We have an itunes account on our desktop and both my kids have it on iphone and ipod. I went in and changed out user name from an old e-mail address which is no longer accessible to my one I use now... When the kids try to sign onto the itunes store it tells them they have the wrong user name..
    Can this be fixed??

    Did you change the email address or create a new Apple ID?
    If the email address associated with the account was merely changed, sign out of the Apple ID on the devices and sign in using the new credentials.

  • How do i set up the eprint from my blackberry so i can send emails to my printer and print them off

    how do i set up eprint on my blackberry so i can send emails from my phone to the printer and print off

     Hi Tanya_Carroll,
    You can follow this link to set up ePrint. 
    http://h71028.www7.hp.com/hho/us/en/ep/articles/setting-up-mobile-printing.html
    Once ePrint is setup, you can send an email to the printer's email address.
    Be sure to use one of these email clients when sending to the printer.  If the Blackberry will not send using your original email address, setup a new email account on the Blackberry and try again.
    Hotmail, Yahoo! Mail, Gmail
    BlackBerry mail clien
    Although I am an HP employee, I am speaking for myself and not for HP.
    If I have resolved your issue, feel free to provide Kudos and make sure you mark this thread as solution provided.

Maybe you are looking for

  • How can I enable Lightroom as a destination in Image Capture?

    Having recently swapped my old iMac for a new Retina MacBook Pro running OS X 10.9.1, I seem to be having some difficulty getting the new Mac to open Lightroom 5.3 when a memory card is inserted either into the SD card slot on the laptop itself or in

  • No life from newly built PC

    So I've installed the mobo, CPU and fan, RAM, and PSU. I've made sure the connections are correct and then I turn it on but nothing at all happens. Not even a fan or any LEDs. I am using a H81M-E33 motherboard, Intel Core i5-4440 CPU, 8 gigs (1 modul

  • BPEL deployment plan in 10.1.3.4

    Hello guys, I've downloaded the MLR patch to upgrade to 10.1.3.4 and wondering where to find and how to use the BPEL deployment plan. According to Robert Zimmerman's presentation titled Oracle BPEL Process Manager Update - April 22 (http://www.oracle

  • Is there a way make an iWeb site appear on Google?

    With other software I know you need code to do that. I was wondering if iBank had some other way to do it since it doesn't let you add code to websites.

  • Adobe upgrade error : The upgrade patch cannot be installed..."

    Hi, I work in an office and while I was trying to patch up some computers that have Adobe 7.0 Pro (others have 8.0 Pro), I received the following message "The upgrade patch cannot be installed by windows installer service because the program to be up