Help Needed in Visual basic coding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ananth
    New Member
    • Nov 2006
    • 75

    #1

    Help Needed in Visual basic coding

    Hi All,
    I have written a code that finds default mail client and then i am using a function to open a mail client and populating it with values.The code works fine when i give some minimum value for the BODY field of the mail.But when i pass String Values with large amount of data the code is not working out.What is this problem due to?I have attached the code below

    Code:
    Option Explicit
    Private 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
    
    Private Const SW_SHOW = 5
    
    
    Public Function OpenEmail(ByVal EmailAddress As String, _
        Optional Subject As String, Optional Body As String) _
        As Boolean
        Dim lWindow As Long
        MsgBox Body
        Dim lRet As Long
        Dim sParams As String
        sParams = EmailAddress
        If LCase(Left(sParams, 7)) <> "mailto:" Then _
            sParams = "mailto:" & sParams
     If Subject <> "" Then sParams = sParams & "?subject=" & Subject
        If Body <> "" Then
            sParams = sParams & IIf(Subject = "", "?", "&")
            sParams = sParams & "body=" & Body
            MsgBox sParams
             End If
       lRet = ShellExecute(lWindow, "open", sParams, _
        vbNullString, vbNullString, SW_SHOW)
       OpenEmail = lRet = 0
    End Function
    
    
    Private Sub Command2_Click()
    Call OpenEmail("ananth_r@xyz.com", "Mac-ID", software_result)
    Unload Me
    End Sub
    please help me in this regard
    Last edited by willakawill; Feb 22 '07, 05:55 PM. Reason: please use code tags when posting code
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Hi. What is software_result and where is it declared?

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Two more questions:
      1. In what way, precisely, does it "not work"? We need specific details.
      2. Are you sure the text you're passing doesn't include characters that might confuse things? For example, what if the text contained "?body=" or something?

      Comment

      Working...