0

At the customers request (sadly) they want their request forms to prompt the local email client for the end user. They don't want to configure SMTP or anything on there end.

I've run into an issue where it works on my local IIS, but doesn't seem to run on our or test server at all. No error is presented in the log, and the compose email doesn't ever popup for sending.

Any ideas? I've looked at security and configuration, but haven't found any differences other than the OS itself. XP Pro -vs- Server.

var mailToLink = "mailto:" + (string)HttpContext.GetGlobalResourceObject ("Portal", "mailToUnInst") + "?subject=" + (string)HttpContext.GetGlobalResourceObject("Portal", "admnTitlUnInst") + " request for " + (string)HttpContext.GetGlobalResourceObject("Portal", "admnTerm") + " " + term.Text + " on " + dtUnInst.Text + "&body=";

mailToLink += (string)HttpContext.GetGlobalResourceObject("Portal", "admnTerm") + " " + term.Text + "%0D%0A"
                    + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnLoc") + " " + loc.Text + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnAddr1") + " " + addr1.Text + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnAddr2") + " " + addr2.Text + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnCity") + " " + city.Text + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnSt") + " " + st.Text + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnZip") + " " + zip.Text + "%0D%0A"
                    + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnAtmType") + " " + atm.Text + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnDtUnInst") + " " + dtUnInst.Text + "%0D%0A"
                    + (string)HttpContext.GetGlobalResourceObject("Portal", "admnRsn") + " " + resn.Text + "%0D%0A"
                    ;

try
{
    System.Diagnostics.Process.Start(mailToLink);
}
catch
{
  //error log process
}

All help greatly appreciated

JonD
  • 1
  • 2
  • 5
  • More code needed. Perhaps the startup parameter `mailToLink` is valid on the IIS machine and not on your local server? What exception/failure code do you get? – Steve Townsend Dec 02 '10 at 16:05
  • What do you expect to happen with the `Process.Start` call on your server? – Dirk Vollmar Dec 02 '10 at 16:16
  • I want the process to basically trigger a compose on the end users computer just like if it was an href tag, but I'm building it in my code behind so I can format it. – JonD Dec 02 '10 at 16:21

2 Answers2

2

First thing to try: what happens on the command line?

start mailto:foo@xyz.com

Does that start the mail client? If not, then it's nothing to do with .NET. (It doesn't work on my netbook either, but then I've never set up a mail client on there...)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
2

Maybe I am getting this wrong, but do you want to call Process.Start on the server to start the user's local email client? This won't work (well, it works only if your web server is running on the local machine in the appropriate context); you should be using mailto-links in your pages:

<a href="mailto:user@example.com?subject=MySubject&body=Hello%20World">Click to send an email</a>

Update

They don't want to configure SMTP or anything on there end.

Without an SMTP server somewhere you won't be able to send email at all, no matter whether you are going to use an email client tool or the .NET classes. You should tell your client that configuration is required, possibly store the STMP server values in your web.config and send the email as described here.

Community
  • 1
  • 1
Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
  • I'm building the input from the form into an email to send. I guess this method won't work? I found the example on here to do it this way. – JonD Dec 02 '10 at 16:16
  • 1
    @JonD: What is supposed to happen on the server? The account used by IIS doesn't have an email client configured. Besides, it doesn't make sense to start an interactive email client on a web server anyway. – Dirk Vollmar Dec 02 '10 at 16:19
  • Since I'm taking in a form and they want the end-users default client to act on the mailto... is there another way to accomplish this? anchor tag isn't really an option that I can see a clean way to impliment. – JonD Dec 02 '10 at 16:34
  • @JonD: How about redirecting to a `mailto:foo@xyz.com?subject=Test` location? – Dirk Vollmar Dec 02 '10 at 16:44