Hi I know how to send the mail from smpt through below mailcode.But not getting any clue on how to send mail from user's outlook.so that user can find his mails in his sent items folder Please help me..
Below is web config codes for sending the mail
<mailSettings>
<smtp>
<network host="11.111.111.1" port="25" defaultCredentials="true"/>
</smtp>
</mailSettings>
and this is my send mail method:
public static void SendMessage(string sbj, string bd, string bccadd, string attachFile1,string buyeremail)
{
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
message.From = new MailAddress(buyeremail);
message.To.Add(new MailAddress(bccadd));
message.Subject = sbj.Trim();
message.Body = bd.Trim();
SmtpClient mysmptclient = new SmtpClient();
mysmptclient.DeliveryMethod = SmtpDeliveryMethod.Network;
message.Attachments.Add(new Attachment(attachFile1));
try
{
message.Attachments.Add(new Attachment(attachFile5));
}
catch
{
}
mysmptclient.Send(message);
}
I just modified my code as below :
try
{
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNamespace = new Outlook.NameSpace("MAPI");
Outlook.MailItem oMailItem = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMailItem.HTMLBody = bd.Trim();
oMailItem.Subject = sbj.Trim();
Outlook.Recipients oRecips = (Outlook.Recipients)oMailItem.Recipients;
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(bccadd);
oRecip.Resolve();
oMailItem.Send();
oRecip = null;
oRecips = null;
oMailItem = null;
oApp = null;
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "');</script>");
//string script = "<script>alert('" + ex.Message + "');</script>";
}
Bu now it shows error: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). Please help me