Tonesterman
MIS
I am attempting to write some VB code that will look at a table and extract the following elements, Associate Email, Associates Name, Reference Number, Amount, Days outstanding, and Managers Email, from a table. Then I would like access to send an email to the Associate with a CC to the Manager. I would like the email to define all of Reference Numbers, Amounts, and Days Outstanding and just populate it in the email. For Example
To: Joe@someplace.com
CC: JoesManager@someplace.com
Subject: Notification of outstanding
Body:
Dear Joe,
The following is outstanding:
Reference Amount Outstanding
*****************************************
ABCD 25.00 10
CDE 45.00 15
DIDID 15.00 10
Then send the next email to the next party in the table and their manager defining their reference numbers.
To: Sam@someplace.com
CC: SamsManager@someplace.com
Subject: Notification of outstanding
Body:
Dear Sam,
The following is outstanding:
Reference Amount Outstanding
*****************************************
IJUK 25.00 10
HHHH 45.00 15
EEEEE 15.00 10
Etc....
Also I would like the email to state another party as the sender (if possible)
Can this be done?
Please note my knowledge of VB is very basic, I have looked on here lots and thanks to another post I can create the email but am unable to send all of the transactions associated to them, it will only do one email per transaction.
Here is the code that I have found on here that has helped me so far:
Private Sub Command12_Click()
On Error GoTo Err_Command12_Click
Dim email As String
Dim body As String
Dim strSQL As String
Dim dbs As DAO.Database
Dim rec As DAO.Recordset
Set dbs = CurrentDb
strSQL = "SELECT * FROM Query1"
Set rec = dbs.OpenRecordset(strSQL, dbOpenDynaset)
Do Until rs.EOF
body = "Dear " & rec![name] & "," & Chr(10)
body = body & "The following is outstanding:" & Chr(10)
body = body & "Reference Number Amount Outstanding" & Chr(10)
body = body & "*****************************************************************************" & Chr(10)
body = body & rec![ref] & " " & rec![outstandingamount] & " " & rec![outstandingdate] & Chr(10)
email = rec!
manager = rec![manager]
DoCmd.SendObject acSendNoObject, , , email, manager, , "Notification of outstanding", body, True
rec.MoveNext
Loop
rec.Close
Set rec = Nothing
Exit_Command12_Click:
Err_Command12_Click:
End Sub
To: Joe@someplace.com
CC: JoesManager@someplace.com
Subject: Notification of outstanding
Body:
Dear Joe,
The following is outstanding:
Reference Amount Outstanding
*****************************************
ABCD 25.00 10
CDE 45.00 15
DIDID 15.00 10
Then send the next email to the next party in the table and their manager defining their reference numbers.
To: Sam@someplace.com
CC: SamsManager@someplace.com
Subject: Notification of outstanding
Body:
Dear Sam,
The following is outstanding:
Reference Amount Outstanding
*****************************************
IJUK 25.00 10
HHHH 45.00 15
EEEEE 15.00 10
Etc....
Also I would like the email to state another party as the sender (if possible)
Can this be done?
Please note my knowledge of VB is very basic, I have looked on here lots and thanks to another post I can create the email but am unable to send all of the transactions associated to them, it will only do one email per transaction.
Here is the code that I have found on here that has helped me so far:
Private Sub Command12_Click()
On Error GoTo Err_Command12_Click
Dim email As String
Dim body As String
Dim strSQL As String
Dim dbs As DAO.Database
Dim rec As DAO.Recordset
Set dbs = CurrentDb
strSQL = "SELECT * FROM Query1"
Set rec = dbs.OpenRecordset(strSQL, dbOpenDynaset)
Do Until rs.EOF
body = "Dear " & rec![name] & "," & Chr(10)
body = body & "The following is outstanding:" & Chr(10)
body = body & "Reference Number Amount Outstanding" & Chr(10)
body = body & "*****************************************************************************" & Chr(10)
body = body & rec![ref] & " " & rec![outstandingamount] & " " & rec![outstandingdate] & Chr(10)
email = rec!
manager = rec![manager]
DoCmd.SendObject acSendNoObject, , , email, manager, , "Notification of outstanding", body, True
rec.MoveNext
Loop
rec.Close
Set rec = Nothing
Exit_Command12_Click:
Err_Command12_Click:
End Sub