Results 1 to 2 of 2

Thread: How do I send email with attachments??

  1. #1

    Thread Starter
    Lively Member spdracr's Avatar
    Join Date
    Oct 2003
    Location
    Kansas
    Posts
    115

    How do I send email with attachments??

    I am needing to click a button which send some parameters to a function which opens the users default email program and creates a new message.

    The code I'm using does this just fine, the only problem is I cannot figure out what the parameter would be in order to attach a file.

    Here is what I am using...
    VB Code:
    1. Public Function OpenEmail(ByVal EmailAddress As String, _
    2.                               Optional ByVal Subject As String = "", _
    3.                               Optional ByVal Body As String = "", _
    4.                               Optional ByVal Attachment As String = "") As Boolean
    5.  
    6.         Dim bAnswer As Boolean = True
    7.         Dim sParams As String
    8.  
    9.         sParams = EmailAddress
    10.  
    11.         If LCase(Strings.Left(sParams, 7)) <> "mailto:" Then _
    12.             sParams = "mailto:" & sParams
    13.  
    14.         If Subject <> "" Then _
    15.             sParams = sParams & "?subject=" & Subject
    16.  
    17.         If Body <> "" Then
    18.             sParams = sParams & IIf(Subject = "", "?", "&")
    19.             sParams = sParams & "body=" & Body
    20.  
    21.             '****** What is the parameter for attaching a file??
    22.             sParams = sParams & "attachment=" & Attachment
    23.  
    24.         End If
    25.  
    26.         Try
    27.             System.Diagnostics.Process.Start(sParams)
    28.         Catch
    29.             bAnswer = False
    30.         End Try
    31.  
    32.         Return bAnswer
    33.  
    34.     End Function
    Could someone please help?!

    Thanks
    CC

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: How do I send email with attachments??

    I don't think you can attach a file that way (not reliably anyway) from what I remember adding an attachment is not part of the official mailto: syntax, which means some email apps like outlook might be able to recognize and use the parameter, while others will not...

    I think automatically adding attachments is a big security risk, which is why it was never implemented as a standard

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