E-mail form

darksniper

Registered User.
Local time
Today, 10:13
Joined
Sep 4, 2005
Messages
108
I got the e-mail code from
http://www.access-programmers.co.uk/forums/showthread.php?t=100584

but I cant seem to implement it. into what I am trying to do. I am trying to make a form that has the names of bunch of people, then in the form I can select multiple people and send them an e-mail, and preferrable type a message that will then when I click send will transfer to outlok from which I just press send putton. well in other to have the same function as outlook express but in access.
 
Thanks for this aleb! I came looking for something to do just this - your example is perfect!

However, I ran across a problem. I use Office 2003, so I had to convert your document (I guess it was Access 97 based?). It ran fine, except one problem.

If I select some names (or just one) in the list on the right, then unselect all, I get an error:

Run-time error '5':
Invalid procedure call or arguement

When I click debug, it highlights the following:

Code:
Private Sub lstMailTo_Click()
Dim varItem As Variant
Dim strList As String

With Me!lstMailTo
    If .MultiSelect = 0 Then
        Me!txtSelected = .Value
    Else
        For Each varItem In .ItemsSelected
            strList = strList & .Column(0, varItem) & ";"
        Next varItem
        [COLOR="Red"]strList = Left$(strList, Len(strList) - 1)[/COLOR]
        Me!txtSelected = strList
    End If
End With
End Sub

How can I stop this error occuring?
 
I seem to have rectified the error. Could anyone tell me if there was a better way? I think this is OK... seems to work!

I added:

Code:
With Me!lstMailTo
    If .MultiSelect = 0 Then
        Me!txtSelected = .Value
    Else
        For Each varItem In .ItemsSelected
            strList = strList & .Column(0, varItem) & ";"
        Next varItem
[COLOR="Red"]        If strList = "" Then
            Me!txtSelected = strList
        Else[/COLOR]
            strList = Left$(strList, Len(strList) - 1)
            Me!txtSelected = strList
[COLOR="Red"]        End If[/COLOR]
    End If
End With

*EDIT* oops! I just changed one slight error in my alteration - it was still outputting the last person's e-mail address! The above should hopefully be OK now :)
 
Last edited:
the program works fine for me, I am using outlook 2003, is it possible to remouve the function that "Makes me choose a repport file before I can press the send button", because I might not want to send a repport every time, or I might want to send another attachement from ms outlook.
 
Hey, I have done exactly this. I didn't want to send a report at all.

Take a look at the DoCmd.SendObject function. You are using objecttype:=acSendReport

I use objecttype:=acSendNoObject, which attaches nothing.

The object types are:

acSendDataAccessPage
acSendForm
acSendModule
acSendNoObject
acSendQuery
acSendReport
acSendTable

You could have an option group to select which type you want. If you didn't select a report with acSendReport, it would throw up an error.

If you have the same problem I did, that the code threw up an error if you deselect all names, then add the code I provided in red above ;)
 

Users who are viewing this thread

Back
Top Bottom