'How to send an outlook mailitem using specific email address?
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.
Solution 1:[1]
If you are sending through Exchange on behalf of another mailbox, set the
MailItem.SentOnBehalfOfName
property (assuming you have sufficient privileges)If you are sending through a particular SMTP account, set the
MailItem.SendUsingAccount
property.If you need to send as an arbitrary SMTP user, see this example on my website - 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.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 (I am its author). See MSOutlook.info for more information.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |