Actually the code is small so here is what I have:
Option Compare Database
Option Explicit
Public Declare Function RegisterWindowMessage _
Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpstring As String) As Long
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As Any) As Long
Public Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal vParam As Long, _
lParam As Any) As Long
Sub Sendmessages(Optional AttachmentPath)
Dim mydb As DAO.Database
Dim rs As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookmsg As Outlook.MailItem
Dim objOutlookrecip As Outlook.Recipient
Dim theaddress As String
Dim asofdate As String
Dim accountnum As String
Dim parishid As String
Dim parishnm As String
Dim pledgeamt As String
Dim receivedamt As String
Dim balance As String
Dim firstnm As String
Dim lastnm As String
Dim wnd As Long
Dim uclickyes As Long
Dim res As Long
'Register a message to send
uclickyes = RegisterWindowMessage("Clickyes_suspend_resume")
'Find ClickYes Window by classname
wnd = FindWindow("Exclickyes_wnd", 0&)
'Send the message to Resume Clickyes
res = SendMessage(wnd, uclickyes, 1, 0)
Set mydb = CurrentDb
Set rs = mydb.OpenRecordset("statement")
rs.MoveFirst
Set objOutlook = CreateObject("outlook.application")
Do Until rs.EOF
Set objOutlookmsg = objOutlook.CreateItem(olMailItem)
theaddress = rs!
asofdate = rs![Date]
accountnum = rs![parishioner_id#]
parishid = rs![organization_id#_receiver]
parishnm = rs![organization_receiver]
pledgeamt = rs![sumofpledge]
receivedamt = rs![sumofamount]
balance = rs![balance]
firstnm = rs![parishioner_firstnm]
lastnm = rs![parishioner_lastnm]
With objOutlookmsg
Set objOutlookrecip = .Recipients.Add(theaddress)
objOutlookrecip.Type = olTo
.Subject = "Giving update" & " " & Date
.Body = "On behalf of all of the individuals, families and" &
vbCrLf & _
"ministries supported by your donation to the Catholic" &
vbCrLf & _
"Services Appeal, thank you for choosing to give!" & vbCrLf & _
vbCrLf & _
"Your giving record as of" & " " & asofdate & " is:" & vbCrLf &
_
vbCrLf & _
"Account number:" & " " & parishid & "-" & accountnum
& vbCrLf & _
"Parish Name:" & " " & parishnm & vbCrLf & _
vbCrLf & _
"Pledge Amount:" & " " & "$ " & pledgeamt & vbCrLf & _
"Received to date:" & " " & "$ " & receivedamt & vbCrLf &
_
" __________" & vbCrLf & _
"Gift remaining:" & " " & "$ " & balance & vbCrLf & _
vbCrLf & _
"Gift enclosed: ______________" & vbCrLf & _
vbCrLf & _
firstnm & " " & lastnm & ", " & "thank you for your continued
support." & vbCrLf & _
vbCrLf & _
"CSA Campaign" & vbCrLf & _
vbCrLf & _
"Diocese of Gaylord" & vbCrLf & _
"611 West North Street" & vbCrLf & _
"Gaylord, MI 49735" & vbCrLf & _
vbCrLf & _
"(Please print and return a copy of this with your gift, thank
you)"
For Each objOutlookrecip In .Recipients
objOutlookrecip.Resolve
If Not objOutlookrecip.Resolve Then
objOutlookmsg.Display
End If
Next
.Send
End With
rs.MoveNext
Loop
Set objOutlookmsg = Nothing
Set objOutlook = Nothing
'Send the message to Suspend ClickYes
res = SendMessage(wnd, uclickyes, 0, 0)
End Sub
Thanks for your help.