Using Access97. Shown below is code taken from my database, which creates email messages and places them in the Outlook Outbox. I need to add a syscmd meter to the code to show progress. Not in the status bar, but the msgbox sort of thing.
Could you edit the code so that when it runs, a meter will shown in the middle of the screen to indicate progress. Also, you must include a comment above each of your additions explaining what the code does, for it to be of use to me.
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim dbs As Database, rst As Recordset
If IsNull(Me.txtSubject) Then
MsgBox "You must enter a subject before despatching e-mails!"
If IsNull(Me.txtNotice) Then
MsgBox "You must enter text before despatching e-mail!"
' Return reference to current database.
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tempFaxtest")
' Populate Recordset object.
' Return to first record.
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
Do While Not rst.EOF
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
' Add the To recipient(s) to the message.
'Set objOutlookRecip = .Recipients.Add(Me![txtemailaddress])
Set objOutlookRecip = .Recipients.Add(rst.resemailtest)
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message.
.Subject = [txtSubject]
.Body = [txtNotice]
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
' Should we display the message before sending?
If DisplayMsg Then
counter = counter + 1
Set objOutlook = Nothing
MsgBox "There was " & counter & " e-mails sent!"
Set dbs = Nothing