Hello,
I have a database which sends emails out to Financial Advisors regarding their clients' accounts. I have the code set up and the email is working properly but I do not know how to insert the "Account_Number" field into the subject line of the email.
I will be sending 15-25 emails at one time and I do not want to have to do this manually. Does anyone know how to do this?
I have a database which sends emails out to Financial Advisors regarding their clients' accounts. I have the code set up and the email is working properly but I do not know how to insert the "Account_Number" field into the subject line of the email.
I will be sending 15-25 emails at one time and I do not want to have to do this manually. Does anyone know how to do this?
PHP:
Public Function SendEMail()
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Set fso = New FileSystemObject
Subjectline$ = "Cancel Request"
If Subjectline$ = "" Then
MsgBox "No subject line, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "E-Mail Merger"
Exit Function
End If
BodyFile$ = "c:\test.txt"
If BodyFile$ = "" Then
MsgBox "No body, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "I Ain’t Got No-Body!"
Exit Function
End If
If fso.FileExists(BodyFile$) = False Then
MsgBox "The body file isn’t where you say it is. " & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "I Ain’t Got No-Body!"
Exit Function
End If
Set MyBody = fso.OpenTextFile(BodyFile, ForReading, False, TristateUseDefault)
MyBodyText = MyBody.ReadAll
MyBody.Close
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set MailList = db.OpenRecordset("MyEmailAddresses")
Do Until MailList.EOF
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.To = MailList("emails")
MyMail.Subject = Subjectline$
MyMail.Body = MyBodyText
MyMail.Send
MailList.MoveNext
Loop
Set MyMail = Nothing
done.
Set MyOutlook = Nothing
MailList.Close
Set MailList = Nothing
db.Close
Set db = Nothing
End Function