Results 1 to 16 of 16

Thread: mailto: Attachment [Unresolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Pittsburgh, PA
    Posts
    329

    mailto: Attachment [Unresolved]

    I'm using:

    VB Code:
    1. BodyData = "Please%20give%20a%20full%20description%20of%20the%20bug%20below%3A%0D%0A%0D%0A"
    2. Attachment = "c:\autoexec.bat"
    3.  
    4. ShellExecute Me.hwnd, "open", "mailto:[email protected]" & _
    5.             "?subject=" & Trim(App.Title) & "%20Bug%20Report" & _
    6.             "&body=" & BodyData _
    7.             & "&attach=" & Chr(34) & Attachment & Chr(34), vbNullString, vbNullString, SW_SHOWNORMAL

    what's wrong? why doesnt the attachment attach??
    Last edited by HAVocINCARNATE29; Jun 2nd, 2003 at 10:20 PM.
    ______________

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Pittsburgh, PA
    Posts
    329
    *bump*
    ______________

  3. #3
    Lively Member ranma_at's Avatar
    Join Date
    Oct 2002
    Location
    @ Home
    Posts
    72
    hmm to me it looks you re just attaching a string not a file;

    U have outlook ?

    VB Code:
    1. Sub OutlookNewMessage()
    2.  
    3. Dim olMail As MailItem
    4. Set olMail = Application.CreateItem(olMailitem)
    5. With olMail
    6. .Subject = "Beergarden"
    7. .Body = "Meet you there"
    8. .attachments.Add _
    9. Source:="C:\Beer.jpg"
    10. .Display
    11. End With
    12.  
    13. End Sub
    Things are not happening to you, things are happening because of you!

  4. #4
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Does ShellExecute and the MailTo functionality allow attachments? I thought it only allowed parameters of MailTo, cc, bcc, Subject and body. See Knowledge Base 188019 on MS site.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Pittsburgh, PA
    Posts
    329
    First thing, i'm try to make this independent of any specific email client, so i dont want to use outlook specific code.

    this example i found implys that you can attach a file...



    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" _
    4.        Alias "ShellExecuteA" _
    5.        (ByVal hwnd As Long, _
    6.         ByVal lpOperation As String, _
    7.         ByVal lpFile As String, _
    8.         ByVal lpParameters As String, _
    9.         ByVal lpDirectory As String, _
    10.         ByVal nShowCmd As Long) As Long
    11.  
    12. Private Const SW_SHOWNORMAL = 1
    13.  
    14. Private Sub SendMail(lhWnd As Long, Optional Address As String, _
    15.     Optional Subject As String, Optional Body As String, _
    16.     Optional CC As String, Optional bcc As String, Optional Attachement As String)
    17.    
    18. '*********************************************************
    19. '********                                         ********
    20. '******** bygger opp en e-post melding, og sender ********
    21. '******** denne ved å benytte default mail system ********
    22. '********                                         ********
    23. '******** NB!! Attachement fungerer KUN med       ********
    24. '******** Outlook og outlook express              ********
    25. '********                                         ********
    26. '*********************************************************
    27.  
    28.     Dim strCommand As String
    29.    
    30.     'bygger opp "mail-strengen"
    31.     If Len(Subject) Then strCommand = "&Subject=" & Subject
    32.     If Len(Body) Then
    33.         Body = Replace(Body, "&", "%26")
    34.         Body = Replace(Body, " ", "%20")
    35.         Body = Replace(Body, vbCrLf, "%0D%0A")
    36.         Body = Replace(Body, vbCr, "%0D")
    37.         Body = Replace(Body, vbLf, "%0A")
    38.         strCommand = strCommand & "&Body=" & Body & "%0D%0A"
    39.     End If
    40.    
    41.     If Len(CC) Then strCommand = strCommand & "&CC=" & CC
    42.     If Len(bcc) Then strCommand = strCommand & "&BCC=" & bcc
    43.     If Len(Attachement) Then strCommand = strCommand & "&Attacth=" & Chr(34) & Attachement & Chr(34)
    44.  
    45.     'passer på at første tegn er et ?-tegn
    46.     If Len(strCommand) Then
    47.         Mid(strCommand, 1, 1) = "?"
    48.     End If
    49.    
    50.     'legger til teksten "mailto:" og hoved adresse
    51.     strCommand = "mailto:" & Address & strCommand
    52.    
    53.     'Starter default mail program v.h.a shellexecute
    54.     Call ShellExecute(lhWnd, "open", strCommand, _
    55.         vbNullString, vbNullString, SW_SHOWNORMAL)
    56.  
    57. End Sub
    58.  
    59. Private Sub Command1_Click()
    60.     SendMail Me.hwnd, "[email protected]", "Test", "Ok, this is the test message.", "[email protected]", , "C:\Autoexec.bat"
    61. End Sub
    ______________

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    The code you posted should send thefilename sent. Does it not work?

    If not, are you sure it's a valid file?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  7. #7
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    Not sure if this will help....but found it when I was searching for close to the same thing awhile back.

    Not the author, so cant take the credit.

    Private Sub cmdEmail_Click()
    Dim emailstuff As String

    emailStuff = App.Path & "\file.mdb"

    MAPISession1.SignOn
    MAPIMessages1.SessionID = MAPISession1.SessionID
    MAPIMessages1.Compose
    MAPIMessages1.RecipAddress = "[email protected]"
    MAPIMessages1.AttachmentPathName = emailStuff
    MAPIMessages1.ResolveName

    MAPIMessages1.MsgSubject = "Place subject here"
    MAPIMessages1.MsgNoteText = "Place message here"
    MAPIMessages1.Send False
    MAPISession1.SignOff

    End Sub

    Hope it helps....

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Pittsburgh, PA
    Posts
    329
    To answer the questions:

    James Stanich: The path is a valid filepath, but its still doesnt attach. I have also tryed changing the code from "Attacth=" to "Attach=" but that didnt help either.

    VB4fun: What component / Reference do i need to add to use MAPISession?


    thanks for all the help so far!
    ______________

  9. #9
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Try changing to attachement.

    You need to add the MAPI controls to your project. If you post your email, I can send you a sample project (too large to load here)
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  10. #10
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    Project|Components|Microsoft MAPI Controls 6.0


  11. #11
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    I use a free add-in called "HTML Mailer". You can download it from the web. It works great and it's free.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Pittsburgh, PA
    Posts
    329
    Thank for the help so far!

    My email is

    havocincarnate29
    @prontomail.com
    ______________

  13. #13
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  14. #14
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by HAVocINCARNATE29
    First thing, i'm try to make this independent of any specific email client, so i dont want to use outlook specific code.

    this example i found implys that you can attach a file...



    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" _
    4.        Alias "ShellExecuteA" _
    5.        (ByVal hwnd As Long, _
    6.         ByVal lpOperation As String, _
    7.         ByVal lpFile As String, _
    8.         ByVal lpParameters As String, _
    9.         ByVal lpDirectory As String, _
    10.         ByVal nShowCmd As Long) As Long
    11.  
    12. Private Const SW_SHOWNORMAL = 1
    13.  
    14. Private Sub SendMail(lhWnd As Long, Optional Address As String, _
    15.     Optional Subject As String, Optional Body As String, _
    16.     Optional CC As String, Optional bcc As String, Optional Attachement As String)
    17.    
    18. '*********************************************************
    19. '********                                         ********
    20. '******** bygger opp en e-post melding, og sender ********
    21. '******** denne ved å benytte default mail system ********
    22. '********                                         ********
    23. '******** NB!! Attachement fungerer KUN med       ********
    24. '******** Outlook og outlook express              ********
    25. '********                                         ********
    26. '*********************************************************
    27.  
    28.     Dim strCommand As String
    29.    
    30.     'bygger opp "mail-strengen"
    31.     If Len(Subject) Then strCommand = "&Subject=" & Subject
    32.     If Len(Body) Then
    33.         Body = Replace(Body, "&", "%26")
    34.         Body = Replace(Body, " ", "%20")
    35.         Body = Replace(Body, vbCrLf, "%0D%0A")
    36.         Body = Replace(Body, vbCr, "%0D")
    37.         Body = Replace(Body, vbLf, "%0A")
    38.         strCommand = strCommand & "&Body=" & Body & "%0D%0A"
    39.     End If
    40.    
    41.     If Len(CC) Then strCommand = strCommand & "&CC=" & CC
    42.     If Len(bcc) Then strCommand = strCommand & "&BCC=" & bcc
    43.     If Len(Attachement) Then strCommand = strCommand & "&Attacth=" & Chr(34) & Attachement & Chr(34)
    44.  
    45.     'passer på at første tegn er et ?-tegn
    46.     If Len(strCommand) Then
    47.         Mid(strCommand, 1, 1) = "?"
    48.     End If
    49.    
    50.     'legger til teksten "mailto:" og hoved adresse
    51.     strCommand = "mailto:" & Address & strCommand
    52.    
    53.     'Starter default mail program v.h.a shellexecute
    54.     Call ShellExecute(lhWnd, "open", strCommand, _
    55.         vbNullString, vbNullString, SW_SHOWNORMAL)
    56.  
    57. End Sub
    58.  
    59. Private Sub Command1_Click()
    60.     SendMail Me.hwnd, "[email protected]", "Test", "Ok, this is the test message.", "[email protected]", , "C:\Autoexec.bat"
    61. End Sub
    hmm those comments are mine...

    attachment part will only work for outlook, not outlook express...
    -= a peet post =-

  15. #15
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    ya got it .......

    The only problem is it's in C++ ...

    http://www.codeproject.com/shell/sendtomail.asp
    http://www.arstdesign.com/articles/sendtomail.html

    can any one convert them to VB ?
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  16. #16
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    Re: mailto: Attachment [Unresolved]

    Originally posted by HAVocINCARNATE29
    I'm using:

    VB Code:
    1. BodyData = "Please%20give%20a%20full%20description%20of%20the%20bug%20below%3A%0D%0A%0D%0A"
    2. Attachment = "c:\autoexec.bat"
    3.  
    4. ShellExecute Me.hwnd, "open", "mailto:[email protected]" & _
    5.             "?subject=" & Trim(App.Title) & "%20Bug%20Report" & _
    6.             "&body=" & BodyData _
    7.             & "&attach=" & Chr(34) & Attachment & Chr(34), vbNullString, vbNullString, SW_SHOWNORMAL

    what's wrong? why doesnt the attachment attach??
    http://www.lencom.com/desc/indexN3946.html

    It's simple little exe file .. but does the job ........
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

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