Skipping lines within a listbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ColinWard

    Skipping lines within a listbox

    Is there any way to skip lines programatically within a listbox as there
    is in a textbox? I have a listbox on a form which gets populated with
    the attachments I want to send with an e-mail but they are all mashed
    together and ideally I would like to skip a line between each
    attachment.

    here is the code:

    For Each vrtSelectedItem In .SelectedItems
    LstAttachment.A ddItem (vrtSelectedIte m)
    -->code to skip a line should go here(I think!)
    Next

    --End code--

    Thank you

    Colin

    P.S. Pieter, If you see this I am still not able to send more than one
    attachment. I do not know where I am going wrong but your continued
    assistance is appreciated!!

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Pieter Linden

    #2
    Re: Skipping lines within a listbox

    ColinWard <jetfighter3@ho tmail.com> wrote in message news:<4148a1e1$ 0$26156$c397aba @news.newsgroup s.ws>...[color=blue]
    > Is there any way to skip lines programatically within a listbox as there
    > is in a textbox? I have a listbox on a form which gets populated with
    > the attachments I want to send with an e-mail but they are all mashed
    > together and ideally I would like to skip a line between each
    > attachment.
    >
    > here is the code:
    >
    > For Each vrtSelectedItem In .SelectedItems
    > LstAttachment.A ddItem (vrtSelectedIte m)
    > -->code to skip a line should go here(I think!)
    > Next
    >
    > --End code--
    >
    > Thank you
    >
    > Colin
    >[/color]
    So when you do something like

    with olkMsg
    .Attachments.Ad d(strFile1)
    .Attachments.Ad d(strFile2)
    .Display
    end with

    you only get one attachment?

    Could you post the part of the code where you add attachments?

    Comment

    • ColinWard

      #3
      Re: Skipping lines within a listbox


      Hi pieter. here is the code for the module that actually composes and
      sends the message.

      --Start Code--

      Public Function SendMessage() As Boolean
      ' The SendMessage() function reads user entered values and
      ' actually sends the message.

      On Error Resume Next

      Dim strRecip As String
      Dim strSubject As String
      Dim strMsg As String
      Dim strAttachment As String

      strSubject = Forms!FrmSendMa il!TxtSubject
      strRecip = Forms!FrmSendMa il!TxtRecipient
      strMsg = Forms!FrmSendMa il!TxtBody
      strAttachment = Forms!FrmSendMa il!LstAttachmen t

      ' Any amount of validation could be done at this point, but
      ' at a minimum, you need to verify that the user supplied an
      ' Email address for a recipient.
      If Len(strRecip) = 0 Then
      strMsg = "You must designate a recipient."
      MsgBox strMsg, vbExclamation, "Error"
      Exit Function
      End If

      ' Assume success
      fSuccess = True

      ' Here's where the real Outlook Automation takes place
      If GetOutlook = True Then
      Set mItem = mOutlookApp.Cre ateItem(olMailI tem)
      mItem.Recipient s.Add strRecip
      mItem.Subject = strSubject
      mItem.Body = strMsg

      ' This code allows for 1 attachment, but with slight
      ' modification, you could provide for multiple files.
      If Len(strAttachme nt) > 0 Then
      mItem.Attachmen ts.Add strAttachment
      End If
      mItem.Send
      End If

      ' Release resources
      Set mOutlookApp = Nothing
      Set mNameSpace = Nothing

      If Err.Number > 0 Then fSuccess = False
      SendMessage = fSuccess
      End Function

      --End Code--

      So somehow I have to get the files that the user picked from the
      openfile dialog and attach them but I cant get my head around how to do
      more than one.

      Thanks Pieter

      Colin




      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • ColinWard

        #4
        Re: Skipping lines within a listbox

        Hi guys.

        I figured out how to skip a line within a listbox. I simply added this
        line within the For Each...Next loop:

        LstAttachment.A ddItem ""

        it works as intended but I am wondering if there any dangers to doing it
        this way?

        thanks

        Colin

        P.S. Pieter, I still haven't figured out my attachment problem. I really
        do appreciate all the help though. I'm sure the problem is my not
        understanding how this loop should work.


        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Pieter Linden

          #5
          Re: Skipping lines within a listbox

          ColinWard <jetfighter3@ho tmail.com> wrote in message news:<41518a36$ 0$26150$c397aba @news.newsgroup s.ws>...[color=blue]
          > Hi guys.
          >
          > I figured out how to skip a line within a listbox. I simply added this
          > line within the For Each...Next loop:
          >
          > LstAttachment.A ddItem ""
          >
          > it works as intended but I am wondering if there any dangers to doing it
          > this way?
          >
          > thanks
          >
          > Colin[/color]

          What happens if the user chooses a blank line? I guess if it's blank,
          there's nothing to add, though...

          "that's the problem with evaporated water... I mean, what do you add?"
          -Steven Wright

          Comment

          • ColinWard

            #6
            Re: Skipping lines within a listbox

            Pieter,

            The listbox simply displays the attachments that were chosen from the
            openfile dialog. The listbo is locked so the user can't do anyhting with
            it anyway.

            thanks pieter

            Colin


            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            Working...