Arvin Meyer's email from access code modification help

J

Jim Ory

WinXP & Access2K2

Using Arvin Myer’s email from access code.

I’ve been asked to provide a way to select all email addresses with a single
cmdButton, instead of clicking on each address in the list box. Is that
possible? Please don’t just answer yes. I need more help in what coding I
need to write.

Thanks.
 
M

Mr B

Jim,

I'm not going to just answer "Yes" but that is the answer if you have set
the Multi select property to "Simple" or "Extended".

You will however need code to actuall have your command button select all
items in the list. Here is a link that should help you:
http://allenbrowne.com/func-12.html

Also, not only will you need code to select all email addresses, but you may
want another button to de-select or clear all selected entities. That is
also discussed in the link above.

You will need to process each item that is selected in the list.

There's code here for walking the selected items in a Multi-select listbox:
http://www.mvps.org/access/forms/frm0007.htm
 
P

Piet Linden

WinXP & Access2K2

Using Arvin Myer’s email from access code.

I’ve been asked to provide a way to select all email addresses with a single
cmdButton, instead of clicking on each address in the list box. Is that
possible? Please don’t just answer yes. I need more help in what codingI
need to write.

Thanks.

you can just add the recipients to the Recipients collection...

Tweak his code a little...

Private Sub Command2_Click()
On Error GoTo ExitHere

Dim varItem As Variant

Dim objOutl As Outlook.Application
Dim objEml As Outlook.MailItem
Dim varMsg As Variant

Set objOutl = CreateObject("Outlook.application")
Set objEml = objOutl.createItem(olMailitem)

'loop through the selected items in your listbox...
For Each varItem In Me.lbxEMail.ItemsSelected
objEml.Recipients.Add Me.lbxEMail.ItemData(varItem)
Next varItem

varMsg = Me.txtMessage
'back to Arvin's code...
With objEml
'.To = strTo <---Already did that with the recipients
collection, so it's commented out.

.Subject = "SUBJECT LINE"

If Not IsNull(varMsg) Then
.Body = varMsg
End If

' Uncomment for attachment
' If Not IsMissing(varAttachment) Then
' .Attachments.Add varAttachment
' End If

'.Display
.Send
End With

Set objEml = Nothing


ExitHere:
Set objOutl = Nothing
'Set objEml = Nothing
End Sub


To test, comment out the
..SEND
and leave just the
..Display

so you can see what's going on. once everything's okay, change back
to just .Send.
 
H

huangda 晋江兴达机械

Jim Ory said:
WinXP & Access2K2

Using Arvin Myer’s email from access code.

I’ve been asked to provide a way to select all email addresses with a
single
cmdButton, instead of clicking on each address in the list box. Is that
possible? Please don’t just answer yes. I need more help in what coding I
need to write.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top