send mail

  • Thread starter Thread starter Ranjit kurian
  • Start date Start date
R

Ranjit kurian

i have query called as qryToday and its in data sheet view, i would like to
send mail to list of people(i have a table with list of mail id and names
'tblNameList' ) the qry Today to everybody who's email id are mentioned in
tblNameList table.

When i click the Cummond Button it should email my query ('qryToday')
information as body to the list of people which has mentioned in tblNameList,
and the mail box used is Outlook.
 
Ranjit kurian said:
i have query called as qryToday and its in data sheet view, i would like to
send mail to list of people(i have a table with list of mail id and names
'tblNameList' ) the qry Today to everybody who's email id are mentioned in
tblNameList table.

When i click the Cummond Button it should email my query ('qryToday')
information as body to the list of people which has mentioned in
tblNameList,
and the mail box used is Outlook.

If you are using Outlook, this code will do what you want:

http://www.datastrat.com/Code/MultipleEmail.txt
 
Hi
Thanks for the code, but when i run the below code i got a error saying
"3265: item not found in collection"



Private Sub Command5_Click()
Call Email
End Sub

Function Email(Optional varMsg As Variant, Optional varAttachment As Variant)
' ©Arvin Meyer 1999-2004
' Permission to use is granted if copyright notice is left intact.
' Permisssion is denied for use with unsolicited commercial email

Dim strTo As String, strSubject As String
'Set reference to Outlook
On Error GoTo Errhandler
Dim strBCC As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim objOutl As Outlook.Application
'Dim objEml As Outlook.MailItem
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset("qryToday", dbOpenSnapshot)

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

With rst
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
End If
End With

For i = 1 To rst.RecordCount
If Len(rst!EmailAddress) > 0 Then
strTo = rst!EmailAddress
Dim objEml As Outlook.MailItem
Set objEml = objOutl.CreateItem(olMailItem)

With objEml
.To = strTo

.Subject = strSubject

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

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

.Send
End With
End If
Set objEml = Nothing
rst.MoveNext
Next i

ExitHere:
Set objOutl = Nothing
'Set objEml = Nothing
Set rst = Nothing
Set db = Nothing

Exit Function

Errhandler:
MsgBox Err.Number & ": " & Err.Description
Resume ExitHere

End Function
 
Hi

Yes i have changed my references to 'Microsoft Outlook 11.0 Object Library

and just copied and saved your funtion and created a command button which
calls the function as shown below

Private Sub Command3_Click()
Call Email
End Sub

Now when i try to run iam geting error called as "Argument not optional"

Please advise me.........
 
I've had to add & "" after email address to get around argument not optional
even though the field does have valid text.
 
Set objOutlook = CreateObject("Outlook.application") is generating error:
429: ActiveX component can't create object.
 
Back
Top