Results 1 to 12 of 12

Thread: Shellexecute, Mailto and Attachment problem..

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297

    Shellexecute, Mailto and Attachment problem..

    Hey All,

    I'm using the following line of code:

    Code:
            ShellExecute 0&, vbNullString, "mailto:?subject=AXIAR Email" & _
            "&Attach=" & Chr(34) & DataKeyPath & Chr(34), _
              vbNullString, "C:\", vbNormal
    And recieving the following error from outlook:

    "Command Line argument not valid. Please verify the switch you are using".

    Any ideas?

    Thanks!

  2. #2
    Lively Member BradBrening's Avatar
    Join Date
    Oct 2001
    Location
    Gillespie, IL
    Posts
    102

    Re: Shellexecute, Mailto and Attachment problem..

    Originally posted by BenFinkel
    Hey All,

    I'm using the following line of code:

    Code:
            ShellExecute 0&, vbNullString, "mailto:?subject=AXIAR Email" & _
            "&Attach=" & Chr(34) & DataKeyPath & Chr(34), _
              vbNullString, "C:\", vbNormal
    And recieving the following error from outlook:

    "Command Line argument not valid. Please verify the switch you are using".

    Any ideas?

    Thanks!
    You can try adding the email address right before the "?", see if that helps.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Tried that, no luck. I also tried "attachment" versus "attach". I'm using outlook 2003, if that makes any difference.

    Thanks,

    Ben

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    VB Code:
    1. ShellExecute 0&, vbNullString, "mailto:?subject=AXIAR Email&attach=" & Chr(34) & "C:\boot.ini" & Chr(34), vbNullString, "C:\", vbNormal

    This worked fine, except it didn't attach a file.

    Related topics:
    http://www.vbforums.com/showthread.p...o+shellexecute
    http://www.vbforums.com/showthread.p...o+shellexecute

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    I'm not sure, but I think you need to url encode it in order for it to work right. Meaning spaces get converted to %20, I'm guessign the : and \ also need to be converted accordingly.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Ah yes, I completely forgot about that. This is my old and slow, but working encoder...

    VB Code:
    1. Function URLencode(Text As String) As String
    2.     Dim A As Long, Temp As String
    3.     For A = 1 To Len(Text)
    4.         Temp = Temp & "%" & Right$("0" & Hex$(Asc(Mid$(Text, A, 1))), 2)
    5.     Next A
    6.     URLencode = Temp
    7. End Function

    And use like:

    ..."&attach=" & Chr$(34) & URLencode(Filename) & Chr$(34)...

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Hey Guys,

    That was good input. It got rid of the error message, but still no file attached (like Merri saw).

    Any other ideas? I feel like we're making progress.

    --Ben

  8. #8
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Hmm... try without Chr$(34) afterall?

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Addendum:

    If I use Chr(34) surrounding the filename I get the same error message still. If I use nothing or Chr(39) (single quote) then I recieve no error, the email starts, and no file is attached.

    --Ben

  10. #10
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    More information: "&Attach=" & Chr$(34) & Filename & Chr$(34) works for Outlook, but doesn't work for Outlook Express (according to a site from Google I found). There was no solution to this problem, but I'll continue the search...

    Edit Found this code

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Yea,

    I had seen that SendKeys code also.. it seems like a hokey way to handle it though.

  12. #12
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Yeah, that's what I thought too. And making a build-in e-mail sender isn't probably worth the effort... I didn't find anything from PlanetSourceCode either.

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