Sending mail with outlook from Asp.Net
-
Hello, I am trying to send email from Microsoft outlook from my application, and I wrote following code : string stSubject=""; string stTo=""; string stCC=""; string stAttachmentFileName = ""; string stDisplayName = ""; string stBody = ""; ApplicationClass oApplicationClass = new ApplicationClass(); NameSpace oNS = null; MailItem oMailItem= (MailItem)oApplicationClass.CreateItem(OlItemType.olMailItem); //stSubject is the mail subject oMailItem.Subject = stSubject; //stTo is the email to address // oMailItem.From = "m.r.chavan@amc.nl"; oMailItem.To = "aa@aa.nl"; oMailItem.CC = "bb@bb.nl"; oMailItem.BodyFormat = OlBodyFormat.olFormatHTML; //if you want it in the plain format, you can set body format as oMailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; oMailItem.HTMLBody = stBody; //oMailItem.Attachments.Add(stAttachmentFileName,(int)OlAttachmentType.olByValue,stBody.Length+1,stDisplayName); oMailItem.Display(true); Can anybody tell me how can i set the oMailItem.From in the mail, I know that the outlook is taking the default user account for mailing, but can I set the FROM property ?
-
Hello, I am trying to send email from Microsoft outlook from my application, and I wrote following code : string stSubject=""; string stTo=""; string stCC=""; string stAttachmentFileName = ""; string stDisplayName = ""; string stBody = ""; ApplicationClass oApplicationClass = new ApplicationClass(); NameSpace oNS = null; MailItem oMailItem= (MailItem)oApplicationClass.CreateItem(OlItemType.olMailItem); //stSubject is the mail subject oMailItem.Subject = stSubject; //stTo is the email to address // oMailItem.From = "m.r.chavan@amc.nl"; oMailItem.To = "aa@aa.nl"; oMailItem.CC = "bb@bb.nl"; oMailItem.BodyFormat = OlBodyFormat.olFormatHTML; //if you want it in the plain format, you can set body format as oMailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; oMailItem.HTMLBody = stBody; //oMailItem.Attachments.Add(stAttachmentFileName,(int)OlAttachmentType.olByValue,stBody.Length+1,stDisplayName); oMailItem.Display(true); Can anybody tell me how can i set the oMailItem.From in the mail, I know that the outlook is taking the default user account for mailing, but can I set the FROM property ?
You should system.net.mail to send mail from server code in asp.net. I doubt very much you can mail from a clients machine.
I didn't get any requirements for the signature
-
Hello, I am trying to send email from Microsoft outlook from my application, and I wrote following code : string stSubject=""; string stTo=""; string stCC=""; string stAttachmentFileName = ""; string stDisplayName = ""; string stBody = ""; ApplicationClass oApplicationClass = new ApplicationClass(); NameSpace oNS = null; MailItem oMailItem= (MailItem)oApplicationClass.CreateItem(OlItemType.olMailItem); //stSubject is the mail subject oMailItem.Subject = stSubject; //stTo is the email to address // oMailItem.From = "m.r.chavan@amc.nl"; oMailItem.To = "aa@aa.nl"; oMailItem.CC = "bb@bb.nl"; oMailItem.BodyFormat = OlBodyFormat.olFormatHTML; //if you want it in the plain format, you can set body format as oMailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; oMailItem.HTMLBody = stBody; //oMailItem.Attachments.Add(stAttachmentFileName,(int)OlAttachmentType.olByValue,stBody.Length+1,stDisplayName); oMailItem.Display(true); Can anybody tell me how can i set the oMailItem.From in the mail, I know that the outlook is taking the default user account for mailing, but can I set the FROM property ?
milindchavan12 wrote:
I am trying to send email from Microsoft outlook from my application,
What does it mean? You want to send mail from ASP.NET Application? Did you googled for that?
milindchavan12 wrote:
Can anybody tell me how can i set the oMailItem.From in the mail, I know that the outlook is taking the default user account for mailing, but can I set the FROM property ?
Why? what happend when you set the From property of MailMessage object?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net