Hi,
I have managed to write some code to create a text file and email it as an attachment using the Reference method (early binding), but I fear I will run into problems when I put the DB on a machione that has a earlier version of Outlook.
I have searched and found several mentions of 'Late Binding' being the way I need to go but I cannot get it to work.
I would appreciate some help with any or all the follwoing possible solutions (and any others that you might think of)
1. To set the refernence in the code, and if there is an error, just run 'some other code' to create the text fil only and display a msgbox informing the user
2. Use late binding to send an email
3. Can code be used to send the email using smtp direct from the system.
Current code is :
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$ = "On Movement File"
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("email")
MyMail.Subject = Subjectline$
MyMail.Attachments.Add "c:\movement\bcms.txt", olByValue, 1
MyMail.Send
MailList.MoveNext
Loop
Set MyMail = Nothing
MyOutlook.Quit
Set MyOutlook = Nothing
MailList.Close
Set MailList = Nothing
db.Close
Set db = Nothing
End Function
Thanks to anyone who takes a loko at this and spends even a few minutes pondering it.
Regards,
John
I have managed to write some code to create a text file and email it as an attachment using the Reference method (early binding), but I fear I will run into problems when I put the DB on a machione that has a earlier version of Outlook.
I have searched and found several mentions of 'Late Binding' being the way I need to go but I cannot get it to work.
I would appreciate some help with any or all the follwoing possible solutions (and any others that you might think of)
1. To set the refernence in the code, and if there is an error, just run 'some other code' to create the text fil only and display a msgbox informing the user
2. Use late binding to send an email
3. Can code be used to send the email using smtp direct from the system.
Current code is :
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$ = "On Movement File"
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("email")
MyMail.Subject = Subjectline$
MyMail.Attachments.Add "c:\movement\bcms.txt", olByValue, 1
MyMail.Send
MailList.MoveNext
Loop
Set MyMail = Nothing
MyOutlook.Quit
Set MyOutlook = Nothing
MailList.Close
Set MailList = Nothing
db.Close
Set db = Nothing
End Function
Thanks to anyone who takes a loko at this and spends even a few minutes pondering it.
Regards,
John