e-mail files
-
Hi, I'd like to pass files to the default mail user agent. What trying to do exactry is to do the same in Windows XP (Open "My Pictures" and select files then click on "E-mail this file" link in the task pane menu on the left). If you know a good way to solve, please let me know. Thanks in advance for your kindness.
-
Hi, I'd like to pass files to the default mail user agent. What trying to do exactry is to do the same in Windows XP (Open "My Pictures" and select files then click on "E-mail this file" link in the task pane menu on the left). If you know a good way to solve, please let me know. Thanks in advance for your kindness.
P/Invoke
ShellExecute(0,"open","mailto:?file=\"c:\autoexec.bat\"", NULL, NULL, SW_SHOWNORMAL);
-
P/Invoke
ShellExecute(0,"open","mailto:?file=\"c:\autoexec.bat\"", NULL, NULL, SW_SHOWNORMAL);
-
P/Invoke
ShellExecute(0,"open","mailto:?file=\"c:\autoexec.bat\"", NULL, NULL, SW_SHOWNORMAL);
Thanks > Dmitriy, However I'm not willing to use P/Invoke. I haven't tested yet but I'd like to use managed code. I tried with Process.Start() but no luck so far. Is there any other way? #BTW: Is following command (with cmd.exe) can be used to test? cmd> explorer.exe mailto:?file=\"c:\autoexec.bat"
-
Jonathan, FYI: http://www.codeproject.com/managedcpp/pinvoke.asp
-
ShellExecute
is one of shell functions so you have to import it viaDllImport
,so check for it in MSDN. But I don't know why he didn't recommend you the .NET way:Process.Start()
Mazy No sig. available now. -
Thanks > Dmitriy, However I'm not willing to use P/Invoke. I haven't tested yet but I'd like to use managed code. I tried with Process.Start() but no luck so far. Is there any other way? #BTW: Is following command (with cmd.exe) can be used to test? cmd> explorer.exe mailto:?file=\"c:\autoexec.bat"
You can do it either way using the following:
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;public class Send
{
private static void Main(string[] args)
{
if (args.Length != 1) return;ProcessStartInfo psi = new ProcessStartInfo(); psi.UseShellExecute = true; psi.FileName = string.Concat("mailto:?file=", Path.Combine( Environment.CurrentDirectory, args\[0\])); psi.FileName = psi.FileName.Replace(" ", "%20"); // Simple, not comp. Console.WriteLine("Executing '{0}'...", psi.FileName);
Process.Start(psi);
// OR Process.Start(psi.FileName);
}
}The problem with this method is that not every client (like Outlook) support the
file
segment in a URL this way. If you want to do this the right way, you'll have to use MAPI which most major email readers support (in order to be a default mail reader, they have to). There are several articles on this on CodeProject. Just try this search: http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=MAPI[^].-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
You can do it either way using the following:
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;public class Send
{
private static void Main(string[] args)
{
if (args.Length != 1) return;ProcessStartInfo psi = new ProcessStartInfo(); psi.UseShellExecute = true; psi.FileName = string.Concat("mailto:?file=", Path.Combine( Environment.CurrentDirectory, args\[0\])); psi.FileName = psi.FileName.Replace(" ", "%20"); // Simple, not comp. Console.WriteLine("Executing '{0}'...", psi.FileName);
Process.Start(psi);
// OR Process.Start(psi.FileName);
}
}The problem with this method is that not every client (like Outlook) support the
file
segment in a URL this way. If you want to do this the right way, you'll have to use MAPI which most major email readers support (in order to be a default mail reader, they have to). There are several articles on this on CodeProject. Just try this search: http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=MAPI[^].-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----