Sending Emails from Access 2000

L

Larry Bitler

Is there any way to set the code so the emails will be
sent automaticaly without keyboard interaction.

This is the code I am using:

Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)
Dim dbs As Database
Dim rst As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim MyBodyText As String

'Set the Subjectline

Subjectline = "Your Current PTO Time Available"

'Set the application

Set MyOutlook = New Outlook.Application


'Set up the database and query connections

Set dbs = CurrentDb

Set rst = dbs.OpenRecordset("MyEmailAddresses",
dbOpenDynaset)

'Set up emails

Do Until rst.EOF

Set MyMail = MyOutlook.CreateItem(olMailItem)

MyMail.To = rst!email

MyMail.Subject = Subjectline

MyMail.Body = "Your current PTO is " + rst!PTO + "
hours."

MyMail.Send

rst.MoveNext

Loop

'Cleanup

Set MyMail = Nothing


MyOutlook.Quit
Set MyOutlook = Nothing
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
End Sub

Any help would be greatly appreciated.
 
A

Adam

Have you tried using DoCmd.SendObject instead of the code you are using? I
think that has an option that sends the email without user interaction.

HTH

Adam
 
A

ali kwok

As far as I know the only way to accomplish unattended
email from VBA is using the CDO for Exchange 2000
interface. If you don't have any luck searching the MSDN
for the info, reply here. I have used it in the past.

Have fun

Ali
 
L

Larry Bitler

This will not work either.

Further research reveals that any OutLook with the
Seciurity patch installed will no longer send unattended
emails but requires operator intervention. A step
backwards.

Thanks for the help.

Larry
 
L

Larry Bitler

Will this code work with the OuyLook security patch
installed as this is what is causing the problem.

If it will could you please send me a sample of the code
to (e-mail address removed)

Thanks for the help,
Larry
 
G

Guest

Larry

Yes this interface doesn't use the OL object model at all. You can find sample code here

http://msdn.microsoft.com/library/en-us/wss/wss/_cdo_creating_a_message.asp

Just follow the steps as appropriate using the tree in hte left-hand pane to navigate

Have fun, Al

----- Larry Bitler wrote: ----

Will this code work with the OuyLook security patch
installed as this is what is causing the problem

If it will could you please send me a sample of the code
to (e-mail address removed)

Thanks for the help
Larr
-----Original Message----
As far as I know the only way to accomplish unattended
email from VBA is using the CDO for Exchange 2000
interface. If you don't have any luck searching the MSDN
for the info, reply here. I have used it in the past
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top