trying to send open the email application

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

At some stage I want to open the user's email client.

I do the following
string dst = "(e-mail address removed)";
string subject = "[Important]";
string body = @"some
multiline
content";
string eMailLink = "mailto:"+dst+"?subject"+subject+"&body="+body;

PropcessStart psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = eMailLink;
Process.Start(psi);

This works fine except I don't get the line return ('\n') in the mail, so I
tried:
body = HttpUtility.UrlEncode(body);
or
body = body.Replace("\r\n", %A0");

In both cases when I call Process.Start(psi); I get
System.ComponentModel.Win32Exception was unhandled
Message="Access is denied"
Source="System"
ErrorCode=-2147467259
NativeErrorCode=5
StackTrace:
at
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at NovaMind.GUI.Dialogs.ExceptionBox.ShowException(Exception ex) in
C:\Lloyd-Dev\MacNetBridge-v1\NovaMindViewer\NovaMind.GUI\Dialogs\ExceptionBox.cs:line
31

Any ideas?
 
Lloyd said:
At some stage I want to open the user's email client.

I do the following
string dst = "(e-mail address removed)";
string subject = "[Important]";
string body = @"some
multiline
content";
string eMailLink = "mailto:"+dst+"?subject"+subject+"&body="+body;

PropcessStart psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = eMailLink;
Process.Start(psi);

This works fine except I don't get the line return ('\n') in the mail, so I
tried:
body = HttpUtility.UrlEncode(body);
or
body = body.Replace("\r\n", %A0");

In both cases when I call Process.Start(psi); I get
System.ComponentModel.Win32Exception was unhandled
Message="Access is denied"
Source="System"
ErrorCode=-2147467259
NativeErrorCode=5
StackTrace:
at
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at NovaMind.GUI.Dialogs.ExceptionBox.ShowException(Exception ex) in
C:\Lloyd-Dev\MacNetBridge-v1\NovaMindViewer\NovaMind.GUI\Dialogs\ExceptionBox.cs:line
31

Any ideas?

That's because you're trying to start the process on the server side
rather than the client side. I think you need to take your mailto link,
add it to a link, send the response to the client, then have some
javascript on the client side "click" the link.

Damien
 
Damien said:
Lloyd said:
At some stage I want to open the user's email client.

I do the following
string dst = "(e-mail address removed)";
string subject = "[Important]";
string body = @"some
multiline
content";
string eMailLink = "mailto:"+dst+"?subject"+subject+"&body="+body;

PropcessStart psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = eMailLink;
Process.Start(psi);

This works fine except I don't get the line return ('\n') in the mail, so I
tried:
body = HttpUtility.UrlEncode(body);
or
body = body.Replace("\r\n", %A0");

In both cases when I call Process.Start(psi); I get
System.ComponentModel.Win32Exception was unhandled
Message="Access is denied"
Source="System"
ErrorCode=-2147467259
NativeErrorCode=5
StackTrace:
at
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at NovaMind.GUI.Dialogs.ExceptionBox.ShowException(Exception ex) in
C:\Lloyd-Dev\MacNetBridge-v1\NovaMindViewer\NovaMind.GUI\Dialogs\ExceptionBox.cs:line
31

Any ideas?

That's because you're trying to start the process on the server side
rather than the client side. I think you need to take your mailto link,
add it to a link, send the response to the client, then have some
javascript on the client side "click" the link.

Damien

Sorry. Please ignore. Forgot which group I was reading (framework
rather than framework.aspnet), and get so used to seeing people trying
to fire things on the clients machines using server code that my brain
switched off completely.

Damien
 
Sorry. Please ignore. Forgot which group I was reading (framework
rather than framework.aspnet), and get so used to seeing people trying
to fire things on the clients machines using server code that my brain
switched off completely.
doh...
I was about to say "what? but.. but it's a winform app!" ;-)
hehe... good laugh!
 
Back
Top