Programmatically sending email using a different Id

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="padding-right:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; text-align:left
Using outlook API, am able to send email without setting any senders email Id. Heres my C# code:
<pre class="lang-cs prettyprint" style="padding-bottom:5px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; overflow-x:auto; overflow-y:auto; width:auto; max-height:600px; text-align:left <code style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Outlook<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Application<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent oApp <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <span class="kwd" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#00008b new<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Outlook<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Application<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <br/><span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Outlook<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af MailItem<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent email <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Outlook<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af MailItem<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 )(<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent oApp<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af CreateItem<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Outlook<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af OlItemType<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent olMailItem<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 ));<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <br/>email<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Recipients<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Add<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#800000 "test@abc.com"<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <br/><span class="com" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:gray //email.Sender.Address = "testaccount@abc.com";<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <br/>email<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Subject<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <span class="str" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#800000 "TestSubject"<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 ;<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <br/>email<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Body<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <span class="str" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#800000 "TestBody"<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 ;<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <br/><span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 ((<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Outlook<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af MailItem<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 )<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent email<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 ).<span class="typ" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#2b91af Send<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; vertical-align:baseline; background-color:transparent <br/>[/code][/code]
<p style="padding-right:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; text-align:left
If I want to send this mail using a different email Id, say testsender@abc.com, what do I need to do?
<p style="padding-right:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; text-align:left
Please advise.
<p style="padding-right:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; text-align:left
Thanks.

View the full article
 
Back
Top