C#: Sending email from a specific account when multiple accounts exist in Outlook?

Somehow I accidentally deleted this message trying to edit it... sorry.
Microsoft.Office.Interop.Outlook.Application outApp = null;
outApp = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
MailItem mailItem = (MailItem)outApp.CreateItem(OlItemType.olMailItem);
mailItem.Subject = "Director Script Confirmation Request";
mailItem.To = person;
mailItem.Body = message;
//mailItem.Display(false);
mailItem.Send();
How do I send email from a specific account when multiple accounts exist in Outlook?
Below is the code that I have. I think I'm supposed to use the AddressEntry or AddressEntries to designate where emails are sent from. However, at the moment, I haven't found an example.
SV

Hello SV,
The MailItem class provides the
SendUsingAccount property which allows to set an Account object
that represents the account under which the MailItem is
to be sent. Here is what MSDN states:
The SendUsingAccount property can be used to specify the account
that should be used to send the MailItem when the Send method
is called.
Sub SendUsingAccount()
Dim oAccount As Outlook.account
For Each oAccount In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("[email protected]")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub

Similar Messages

  • Cant send emails from gmail or yahoo when connected to vpn

    I use a vpn to mask my IP address. When I am connected through my VPN I cannot send emails from my gmail or yahoo accounts through thunderbird
    If i disconect vpn they go through fine

    Just a guess, but if you change the outgoing server name to an IP address such as 74.125.136.108 for Gmail, does it work?
    https://support.hidemyass.com/entries/24893686-SMTP-Sending-emails-while-connected-to-VPN#thunderbird

  • TS3276 it always sends email from a specific account

    I have set up 2 accounts in my Mac email - A & B. When I send any email, it always sends it from B, even when 'from' field has A.

    Check what SMTP server both accounts are using. A should be using the SMTP server for your A account and B should be using the B SMTP server.
    Now if both those accounts are from the same ISP and or Email provider, like Apple or google or yahoo, then the SMTP server will be the same for both. Just the Return address, the email address for each account, will be different.

  • Changed e-mail password in windows live account - now cannot send email from iphone.  Have deleted the account from the iphone and reinstalled it - the password is correct - still no luck - any advice ?

    I changed the password in my windows live e-mail account.  My iphone now recieves but will no longer send e-mails.  I have deleted the account from the iPhone - reinstalled it and verified the password is correct.  I recieve a message that "Cannot Send Mail"  "the user name or password ... is incorrect.  Any advice ?

    Hello DRB1962
    Check to make sure that you validated the device within your account on webmail.
    iOS: Setting up Hotmail, Outlook, Live, or MSN email accounts
    http://support.apple.com/kb/HT1694
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • Can't send email from one specific .mac account

    I have two .mac accounts on three different machines. My main email account gives me "cant send with server smtp message..." use a different server. I can send just fine with my other .mac acct on the same machine. But I can't send from my main .mac acct on any of the machines or the web client at home or work. I have created a new user from scratch and set up the .mac acct on it and still get the errors. So it doesn't seem to be a problem specific to machine, user, or network. Any suggestions would be greatly appreciated.
    Thanks
    iMac intel   Mac OS X (10.4.6)  

    In your Account setup (via Mail Preferences) you may have to set up an Outgoing Mail Server (SMTP) entry. As an example I have a IMAP account and a POP account. The IMAP account has the server smtp.<imap_domain>.com and the POP account has mail.<pop_domain>.net.au. I also have other domain entries which come into play if I am visiting friends or colleagues and need to send or receive mail via their broadband links which have ISP's that differ to mine.
    Chris

  • Cannot send email from my 4S on my ISP account (essex1).

    I recieve an error message that tells me that the recipient (email addy) was rejected by the server.  My ISP provided the required settings; still cannot send from my iPhone. 
    I recently upgraded to the newer IOS.
    A bit of help, please!

    First you have to find out on what PORT the SMTP your "College" is allowing through there firewalls. Then in Mail go to the Mail menu item name "Mail" and in it's drop-down select Preferences. Then click on the account for your "College" email servers. Then in the right-hand pane use the SMTP drop-down to edit the SMTP server settings to the SMTP server port your "college" is allowing through.maybe port 587.

  • Load x# of messages when sending email from my pop account

    Hi
    I'm getting a "load x# of messages" when sending email from any address on my pop account. No problem receiving messages from other accounts. Is there a setting that can remedy this?
    Thanks

    My z10 is going back today, for multiple reasons
    Contacts won't sync across
    Won't work properly with my car when all previous BBs did
    Lots of useful features have disappeared
    But most importantly NONE of my email accounts will send mail from it when they all did previously with the Storm2.
    A big thumbs down from me for the z10 even if it is a fancy looking phone and the browser is much better. I stuck with BB because I wanted a tool not a toy

  • Sending emails from Ipad 2

    I can send emails from my Ipad 2 when connected via 3g but when on wifi even in my home it will not send them. my ISP is tiscali  is there another smtp setting that is worth trying.

    I don't know if you saw this discussion from the box on the right - More Like This - or it would apply if you by some chance have a 3G AT&T iPad - but I thought I would pass it along to you just in case.
    https://discussions.apple.com/thread/2123623?start=15&tstart=0
    See the response from Lawrence Finch

  • How can i send emails from forms

    I need to be able to send emails from forms 6.(assuming the pc is running Outlook) What is the best way of doing this? Would OLE or DDE control of Outlook be the easiest method?
    If anyone has done this please let me know.

    See:
    iOS: Unable to send or receive email
    I would Google for:
    setup verizon email on phone
    for the settings to use.

  • Cannot send email from pop account when in 3G, will send in WIFI

    I cannot send email from pop account when in 3G, will send in WIFI.
    I thought it was the SMTP server first.. but when i config my WIFI, suddenly the emails that i tried to send, left my outbox and sent.
    Any idea's

    The SMTP server you are using with Wi-Fi would be the outgoing server of your internet service provider... this is likely why that's working.
    SMTP servers specific to a ISP would not work on the 3G network. You would probably need another SMTP server. One from your cell provider?

  • TS3899 When sending email from the Mail App or through other Apps, my default From: address will change when I enter a To: address.  This sometimes leads me to send the email from the wrong outgoing email account.  It is frustrating and poor design.

    When sending email from the Mail App or through other Apps on my iPad, my default From: address will change when I enter a To: address.  This sometimes leads me to send the email from the wrong outgoing email account.  It is frustrating and poor design, especially since I had already checked the From: address.
    iPad 4 running iOS 8.1.3

    3rd party email addresses have to be deleted on every synmced mac product, although I have 1and1.co.uk and my imac updatetes the mails in that account from mac mail.
    Yahoo etc is a 2 step deleting process but good to get your emails pushed when on the go.
    LJ
    http://www.facebook.com/The.Cowboy.Party

  • How do I set a new account as default in safari when I send emails from a web page

    how do I set a new account as default in safari when I send emails from a web page
    thanks in advance

    In the Composing pane of Mail's preferences window, look for the pop-up menu labeled "Send new messages from." Select the desired account there.
    Note, though, that this won't change the behavior when replying to a message... in that case, the reply will be sent from the account that received the message, unless you specify differently at that time.

  • HT1430 Can anyone help me set up sending email from my o2 email account to my new iPhone 5?  I think I maybe shouldn't have clicked the 'merge' option for iCloud when I set up the first email account (though am not sure whether that's relevant).  Thanks,

    Can anyone help me set up sending email from my o2 email account, for my new iphone? 
    Thanks
    Pamela

    Additonally, at this point I really want to talk to someone who cares about how a customer like I might feel in such a situation and when I call corporate would like to talk to someone who is interested in hearing my input as it really sucks to think I really don't feel like going to the store anymore and would rather just buy stuff on amazon or newegg these days instead;/  When I know how much i used to enjoy going into the store and getting friendly with kind staff who worked with me to get the best deal on the items I got--perhaps this was because it was at a more desperate time when Best Buys fate as a company was more precarious prior to price matching taking origin.  Also, on an aside, would like to add that obviously there is always the one or two people who go out of their way to make sure you have an excellent expeirenece so I am not trying to make any sweeping generalizations here.  In fact, I find the forum contributors to be among the most kind and helpful, but that might be because they don't have to deal with the now seemingly dreaded "pricematch" epidemic;D

  • Sending email from different addresses under one account.

    Hello,
    So, I'm having an issue that's a little bit complicated, and in fact, I don't even know if there is a solution.  But, if anyone knows how to do this, I'd greatly appreciatte your help.
    So, here's what I'm trying to do.
    Right now, I have three different email accounts, an icloud and two gmails.  I have both of those gmails set up so that they forward to my icloud account.  So, in the mail app on my iphone, I only have my icloud account.  I've been trying to reduce clutter by doing this, and it seems to be working pretty well, save for this issue.
    The problem I am having is still being able to respond to emails sent to one of those two gmail accounts with the same email address.  I.e.-if someone emails me at my gmail account, it's then forwarded to icloud, but I still want to respond from that gmail account using the mail app on my iphone.  I'd like to do this without setting adding the two "dead" gmail accounts onto my phone, because everything is more streamlined when I'm only using icloud.
    I've been able to do this using iMail on my mac by adding the two gmail addresses to my icloud account in settings, as well as the gmail server.  So on my mac, I only have icloud set up in imail, but I can compose emails using my two gmail addresses.  I pretty much want to be able to do the same thing on my iphone.
    Does anyone know how this can, or even if, it can be set up?
    Also, if it can't be done in the native mail app to ios, do you know of any third party apps where something like this would be possible?
    Thanks!!1

    Hi 3s1k,
    Thank you for your question.
    When he replies to my email and changes the "send From" 
    to [email protected] and send the email, It will still show that it was sent from @mainDomain.com.
    Now, I think the issue is within his Exchange mailbox, his default reply email address is @MainDomain.com.
    A:You are right. By our testing. We could just send emails with primary address, but we could receive emails with primary address and second address.
    How do I get around this. The client wants to utilize sending email from both domains since he has clients in both domains.
    A: If we want to send email with specific email address, we could manually modify the primary email address to the specific domain by Exchange administrator. And the client didn’t use customized email address to send emails.
    If there are any questions regarding this issue, please be free to let me know. 
    Best Regard,
    Jim

  • Cannot send email from yahoo account on iPhone 5

    I just got an iPhone5 and I couldn't set up my Yahoo email as "yahoo"--it would not allow me to complete the process despot multiple attempts. I had to set it up as an "other" account. I can receive and read emails on my phone, but when I reply those messages will not send. They go to the outbox and an error message pops up that says" the email account has been rejected by the server" Does anyone have advice on either issue: setting up yahoo properly and/or sending email from phone?

    outgoing mail server
    SMTP - Yahoo! SMTP Server
    primary server
    Yahoo! SMTP server - ON
    server port 465
    That's what I have for my yahoo account.

Maybe you are looking for

  • External Hard Drive no longer being recognized in Finder

    My Seagate Ecternal Firewire hard drive was accidently unplugged a few minutes after transferring about 11gb of files to it. When I plugged it back in it is giving me the Error Message: DISK INSERTION then below that it says "The disk you inserted wa

  • Free Item indicator is SET but value appearing in MB51

    Hello MM Guru's, I have PO with Acc Assignment – Q (Project) and activated Free Item indicator when I do GR with Movement type – 101 / Q accounting document gets generated. As per my understanding SAP standard behavior is if I perform GR for FOC item

  • Error opening Oracle BI Presentation Services

    I am new to obiee. Finished installing Oracle 11g, Oracle BI 10.1.3.4.0, jdk1.6.0-07. I am able to create new repository in BI Administartor Tool. Error while trying to connect to Presentation Services. Theses are the various errors: when connecting

  • Time machine to local sparsebundle...

    Hello everyone! Is it possible to tell time machine to use a local sparsebundle as a backup drive ? I know TM can work with this, since it creates sparsebundles when backing up over network i need this for 2 reasons: i could place a sparsebundle with

  • Upload image using webdynpro abap

    Gudday, I have a requirement to provide three functionalities like 1)browse 2)upload 3)review the image using webdynpro ABAP. I tried with functionn module 'ARCHIV_CREATE_DIALOG_META'  which uploads images..but if i try to use the samething using ser