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. General Programming
  3. .NET (Core and Framework)
  4. Sending E-mail through default settings

Sending E-mail through default settings

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpsysadmintestingtoolsquestion
4 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.
  • J Offline
    J Offline
    Jack Vanderhorst
    wrote on last edited by
    #1

    Morning CPians, dig me out here :) I need to send an E-mail from my app through the default E-mail setup on a client system. (invoices and order confirmations, exciting stuff) I have learned through some Googles that MAPI used to do this (no I haven't tried, it looks pretty old), then MAPI was replaced by System.Web.Mail, which has now been replaced by System.Net.Mail. Great, BUT, these .NET replacements both need to be told the E-mail server's address and/or domain, which my users will definitely not know. The Outlook automation assemblies look like an easy option, but I'd just as soon not limit myself to Outlook, or move outside .NET Is there some way to have System.Net.Mail just send the mail through whatever default E-mail settings exist on a user's machine? Perhaps I can look up the E-mail settings somewhere? Magically impersonate the user? Ideas? Guidance?

    L S 2 Replies Last reply
    0
    • J Jack Vanderhorst

      Morning CPians, dig me out here :) I need to send an E-mail from my app through the default E-mail setup on a client system. (invoices and order confirmations, exciting stuff) I have learned through some Googles that MAPI used to do this (no I haven't tried, it looks pretty old), then MAPI was replaced by System.Web.Mail, which has now been replaced by System.Net.Mail. Great, BUT, these .NET replacements both need to be told the E-mail server's address and/or domain, which my users will definitely not know. The Outlook automation assemblies look like an easy option, but I'd just as soon not limit myself to Outlook, or move outside .NET Is there some way to have System.Net.Mail just send the mail through whatever default E-mail settings exist on a user's machine? Perhaps I can look up the E-mail settings somewhere? Magically impersonate the user? Ideas? Guidance?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I use MailMessage, MailAddress, and SmtpClient classes, and keep some strings as settings, including the mail server name (which SmtpClient constructor needs). I know of no way to solve it without settings for all possible situations. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


      1 Reply Last reply
      0
      • J Jack Vanderhorst

        Morning CPians, dig me out here :) I need to send an E-mail from my app through the default E-mail setup on a client system. (invoices and order confirmations, exciting stuff) I have learned through some Googles that MAPI used to do this (no I haven't tried, it looks pretty old), then MAPI was replaced by System.Web.Mail, which has now been replaced by System.Net.Mail. Great, BUT, these .NET replacements both need to be told the E-mail server's address and/or domain, which my users will definitely not know. The Outlook automation assemblies look like an easy option, but I'd just as soon not limit myself to Outlook, or move outside .NET Is there some way to have System.Net.Mail just send the mail through whatever default E-mail settings exist on a user's machine? Perhaps I can look up the E-mail settings somewhere? Magically impersonate the user? Ideas? Guidance?

        S Offline
        S Offline
        Scott Dorman
        wrote on last edited by
        #3

        If you need it to actually display the message in the users default email client (like Outlook, Live Mail, etc.) you can use some interop to MAPI, but you need to be very careful about resource leaks. Keep in mind that this isn't officially supported and is actually not recommended, but I think as long as you are careful and only use it to open a mail message it's safe. Otherwise, you can use the built-in .NET classes but you will need to ask the user for the email server. You can save that information as a setting somewhere so you only need to ask for it once, but there isn't a way (as far as I know) to automatically get that information.

        Scott Dorman

        Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


        Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

        J 1 Reply Last reply
        0
        • S Scott Dorman

          If you need it to actually display the message in the users default email client (like Outlook, Live Mail, etc.) you can use some interop to MAPI, but you need to be very careful about resource leaks. Keep in mind that this isn't officially supported and is actually not recommended, but I think as long as you are careful and only use it to open a mail message it's safe. Otherwise, you can use the built-in .NET classes but you will need to ask the user for the email server. You can save that information as a setting somewhere so you only need to ask for it once, but there isn't a way (as far as I know) to automatically get that information.

          Scott Dorman

          Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


          Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

          J Offline
          J Offline
          Jack Vanderhorst
          wrote on last edited by
          #4

          Hrmph. Thanks very much both of you, I suspected as much. Cheers! -Jack

          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