0
votes

Hi does anyone know how to send or reply to an outlook mailitem using a specific string of email address?

FOR EXAMPLE:

my outlook email address is:

string email = "[email protected]";

now instead of my outlook email address, i want to use (email address from a specific mailbox on my outlook):

string email = "[email protected]";

I already tried using this:

Outlook.Accounts accounts = application.Session.Accounts; 
foreach (Outlook.Account account in accounts) 
{ 
    // When the e-mail address matches, return the account. 
    if (account.SmtpAddress == smtpAddress) 
    { 
        return account; 
    } 
} 

but its only looking up for the accounts on what is in my outlook application.

1
So you want to send a message from an account that is not configured within outlook?Yacoub Massad
@YacoubMassad sorry i just edited my question.joem824
So did you find the right Account?Yacoub Massad
@YacoubMassad no because the email address of that mailbox is not in the account settings :( do you know atleast how to access the email address of that mailbox?joem824
You can't do this, without the primary account being given delegate rights to the other account. Talk to a SMTP server instead.stuartd

1 Answers

1
votes

1) If you are sending through Exchange on behalf of another mailbox, set the MailItem.SentOnBehalfOfName property (assuming you have sufficient privileges)

2) If you are sending through a particular SMTP account, set the MailItem.SendUsingAccount property.

3) If you need to send as an arbitrary SMTP user, see this example - you will essentially need to set the "From" named MAPI property in the PS_INTERNET_HEADERS namespace. Note that not all SMTP servers will let you do that - Exchange for one will not let you spoof the sender.

4) If you want to send as one of the alias (proxy) SMTP addresses belonging to a particular Exchange mailbox, you will need to send through SMTP - sending through OOM or MAPI will always send with the default SMTP address of the mailbox. For an end user, you can configure a dummy POP3/SMTP account or use a product like Proxy Manager. See MSOutlook.info for more information.