• List box entries written to email (97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » List box entries written to email (97)

    Author
    Topic
    #379805

    How might I click on several list box entries & have them be written to the body of an email?

    Viewing 0 reply threads
    Author
    Replies
    • #633715

      If you want the text to be assembled as the uses clicks each list box:

      1. Declare a module-level string variable; it will be used as the message text (body) of the e-mail.
      2. Add portions to the string in the OnClick event of each of the list boxes, something like
      strMessage = strMessage & vbCrLf & lstListbox
      3. Create the e-mail in the OnClick of a command button:
      DoCmd.SendObject ObjectType:=acSendNoObject, MessageText:=strMessage
      (You probably want to set more parameters; look up SendObject in the online help)

      • #633764

        yes but only one list box is involved & it is multi select so I

        • #633771

          If you have a multi-select list box, adding and removing strings on the fly will be a nightmare. I would use a command button instead and use code in the OnClick event that assembles the string variable based on the selected items in the list box:

          Dim i As Long
          Dim strReturn As String
          Const clngColumnToReturn = 0
          For i = 0 To lstMultiSelect.ListCount – 1
          If lstMultiSelect.Selected(i) Then
          strReturn = strReturn & lstExtended.Column(clngColumnToReturn, i) & vbCrLf
          End If
          Next i

          clngColumnToReturn is the zero-based index of the column that contains the text to be used. In the code above, it i 0 (the first column). Change if necessary.

        • #633927

          You wouldn’t remove the value from the string, you would rebuild the entire string without that value in it.

    Viewing 0 reply threads
    Reply To: Reply #633764 in List box entries written to email (97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel