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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. e-mail files

e-mail files

Scheduled Pinned Locked Moved C#
agentic-ai
9 Posts 5 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.
  • K Offline
    K Offline
    Kenneth_i
    wrote on last edited by
    #1

    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.

    D 1 Reply Last reply
    0
    • K Kenneth_i

      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.

      D Offline
      D Offline
      Dmitriy Kostovetskiy
      wrote on last edited by
      #2

      P/Invoke

      ShellExecute(0,"open","mailto:?file=\"c:\autoexec.bat\"", NULL, NULL, SW_SHOWNORMAL);

      L K 2 Replies Last reply
      0
      • D Dmitriy Kostovetskiy

        P/Invoke

        ShellExecute(0,"open","mailto:?file=\"c:\autoexec.bat\"", NULL, NULL, SW_SHOWNORMAL);

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Where can i find the shellexecute function (which namespace) Jonathan Slenders

        M K 2 Replies Last reply
        0
        • L Lost User

          Where can i find the shellexecute function (which namespace) Jonathan Slenders

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          ShellExecute is one of shell functions so you have to import it via DllImport ,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.

          K 1 Reply Last reply
          0
          • D Dmitriy Kostovetskiy

            P/Invoke

            ShellExecute(0,"open","mailto:?file=\"c:\autoexec.bat\"", NULL, NULL, SW_SHOWNORMAL);

            K Offline
            K Offline
            Kenneth_i
            wrote on last edited by
            #5

            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"

            H 1 Reply Last reply
            0
            • L Lost User

              Where can i find the shellexecute function (which namespace) Jonathan Slenders

              K Offline
              K Offline
              Kenneth_i
              wrote on last edited by
              #6

              Jonathan, FYI: http://www.codeproject.com/managedcpp/pinvoke.asp

              1 Reply Last reply
              0
              • M Mazdak

                ShellExecute is one of shell functions so you have to import it via DllImport ,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.

                K Offline
                K Offline
                Kenneth_i
                wrote on last edited by
                #7

                Mazdak, Does Process.Start() can handle it? If you know how to, please let me know. What I am trying to is to emulate one of Windows XP function ("e-mail this file").

                1 Reply Last reply
                0
                • K Kenneth_i

                  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"

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #8

                  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-----

                  K 1 Reply Last reply
                  0
                  • H Heath Stewart

                    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-----

                    K Offline
                    K Offline
                    Kenneth_i
                    wrote on last edited by
                    #9

                    Heath, Thanks a lot. I'll read the articles of MAPI. I hope I don't have to import MAPI32.DLL.

                    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