Hello Everyone,
I have to send mail from one static id to microsoft office outlook.i will send code of my .please help me
sending id="[email protected]";
to:"[email protected]";
public Outlook.Account GetAccountForEmailAddress(Outlook.Application application, string smtpAddress)
{
// Loop over the Accounts collection of the current Outlook session.
Outlook.Accounts accounts = application.Session.Accounts;
foreach (Outlook.Account account in accounts)
{
// When the e-mail address matches, return the account.
if (account.SmtpAddress == "[email protected]")
{
return account;
}
}
throw new System.Exception(string.Format("No Account with SmtpAddress: {0} exists!", smtpAddress));
}
Outlook.Application oApp = new Outlook.Application();
Outlook._NameSpace oNamespace;
Outlook.MAPIFolder oOutbox;
oNamespace = oApp.GetNamespace("MAPI");
oNamespace.Logon(null, null, true, true);
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMsg.Subject = "Sign In......!";
oMsg.To = "[email protected]";
Outlook.Account account = GetAccountForEmailAddress(oApp,"[email protected]");
oMsg.SendUsingAccount = account
oMsg.Send();
oMsg = null;
oApp = null;
to anyone
i hope you will send me help in code
ramya bharathRank #3,780 · 391 reputationPosted Sep 23, 2015, 11:47 AM EDT
Use mailitem.senderemailaddress to fix the address
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 23, 2015, 6:55 PM EDT
Manish Solanki83 reputationPosted Sep 23, 2015, 11:09 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 23, 2015, 11:34 PM EDT
Manish Solanki83 reputationPosted Sep 23, 2015, 11:45 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 23, 2015, 11:47 PM EDT
Manish Solanki83 reputationPosted Sep 24, 2015, 12:34 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 24, 2015, 1:12 AM EDT
Manish Solanki83 reputationPosted Sep 24, 2015, 1:19 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 24, 2015, 1:37 AM EDT
Manish Solanki83 reputationPosted Sep 24, 2015, 2:14 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 24, 2015, 2:28 AM EDT
Manish Solanki83 reputationPosted Sep 24, 2015, 2:33 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 24, 2015, 2:43 AM EDT
Manish Solanki83 reputationPosted Sep 24, 2015, 2:47 AM EDT
Chipp169 reputationPosted Sep 24, 2015, 5:48 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts