CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 1999
    Location
    CA
    Posts
    83

    Opening e-mail and adding an attachment

    I want to add some functionality to an app so that when a user clicks on an email address it will open up the default email browser, so far I can do this using ShellExecute, however I also want to be able to add an attachment automatically if the user has already selected a file. I was just wondering if there was a way to do this. I'm not sure if ShellExecute would work for this, but even so if there is another way I could target certain apps such as Outlook Express and Eudora by having a command line paramter that adds the attachment that would probably work. Any help is greatly appreciated.


  2. #2
    Join Date
    Sep 1999
    Location
    Germany
    Posts
    66

    Re: Opening e-mail and adding an attachment

    Look follow samples

    How to start the default e-mail application
    http://vbcode.webhostme.com/en/click.asp?id=91

    Using MS Outlook to e-mail
    http://vbcode.webhostme.com/en/click.asp?id=92

    Best Regards.

    [email protected]
    http://vbcode.webhostme.com/

  3. #3

    Re: Opening e-mail and adding an attachment

    You may want to consider bypassing the default e-mail app and sending e-mail in your application directly via winsock. There is an example at http://www.freevbcode.com/ShowCode.Asp?ID=109 that is a .dll for this purpose. Attachments are supported.

    This is only for SMTP mail, so if you are supporting another kind of messaging, you can do what the other response suggested, but you will be limited to the outlook client.


  4. #4
    Join Date
    Sep 1999
    Location
    CA
    Posts
    83

    Thanks

    Just wanted to say thanks to the both of you for your help.


  5. #5
    Guest

    Re: Opening e-mail and adding an attachment

    Hi!

    I want to do the same thing that you have done, that is opening the default e-mail application, when the user clicks on the e-mail address which is
    displayed in the msflexgrid. And that e-mail address should be passed on
    to the To: slot of the e-mail application.

    Could you please send me the code for it. I have been trying to do this
    for quite some time. I would really appreciate your help.

    Thanks.


  6. #6
    Join Date
    Sep 1999
    Location
    CA
    Posts
    83

    Here you go

    Sorry it took so long, but my DSL line was down for a while...
    Here's the API call you have to declare in a .bas module
    Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    and here's the function call:
    Dim link As Long
    link = ShellExecute(0&, vbNullString, "mailto:" & EMAIL_ADDRESS_HERE, vbNullString, vbNullString, vbNormalFocus)

    where EMAIL_ADDRESS_HERE is a String variable with the user's email address
    hope this helps


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured