By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Skipping lines within a listbox

P: n/a
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.AddItem (vrtSelectedItem)
-->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!
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
ColinWard <je*********@hotmail.com> wrote in message news:<41**********************@news.newsgroups.ws> ...
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.AddItem (vrtSelectedItem)
-->code to skip a line should go here(I think!)
Next

--End code--

Thank you

Colin

So when you do something like

with olkMsg
.Attachments.Add(strFile1)
.Attachments.Add(strFile2)
.Display
end with

you only get one attachment?

Could you post the part of the code where you add attachments?
Nov 13 '05 #2

P: n/a

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!FrmSendMail!TxtSubject
strRecip = Forms!FrmSendMail!TxtRecipient
strMsg = Forms!FrmSendMail!TxtBody
strAttachment = Forms!FrmSendMail!LstAttachment

' 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.CreateItem(olMailItem)
mItem.Recipients.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(strAttachment) > 0 Then
mItem.Attachments.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!
Nov 13 '05 #3

P: n/a
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.AddItem ""

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!
Nov 13 '05 #4

P: n/a
ColinWard <je*********@hotmail.com> wrote in message news:<41**********************@news.newsgroups.ws> ...
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.AddItem ""

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

thanks

Colin


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
Nov 13 '05 #5

P: n/a
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!
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.