Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Sending mail with outlook from Asp.Net

Sending mail with outlook from Asp.Net

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-net
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Milind R Chavan
    wrote on last edited by
    #1

    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 ?

    T A 2 Replies Last reply
    0
    • M Milind R Chavan

      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 ?

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • M Milind R Chavan

        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 ?

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups