dipitiduda2
Technical User
Hello All,
Need assistance for MS Access to Outlook XP tasks using Visual Basic....here's the problem:
Have a dBase set up that generates reports based on multiple ID's with page breaks separating the distinct records. This report is based on a CLICK event in the form's sub procedure. The form's sub CALLS the basModule that then writes the data as a .pdf file (using a standard module) and sends it to Outlook as email attachments (or so I think-cannot test it far enough to tell).
The problem arises when Outlook detects the vb script trying to access Outlook and a MsgBox (vbYesNoHelp) states: "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may.......". It does not allow me to send unsecured messages for a limited time, only allows me to CLICK the 'Yes' option twice. And, then I CLICK on a MsgBox (vbOKOnly) that states: "Object doesn't support this property or method.".
Question: What property or method is MS Access referring to? I cannot trace the code back to the debugger that is generating this error message. Also, why will MS Outlook not allow me to override the unsecured message function?
I have provided coding below for the sub procedure where the error message is occurring.
Any assistance is sincerely appreciated.
Private Sub cmdEMailRpts_Click()
On Error GoTo Err_cmdEMailRpts_Click
Dim stDocName As String
Dim Name As String
Dim objOutLook As Outlook.Application
Dim objOutLookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
'Set the Oulook session.
Set objOutLook = CreateObject("Outlook.Application"
'Create the message.
Set objOutLookMsg = objOutLook.CreateItem(olMailItem)
Call SaveReportAsPDF("rpt_ExpenseRpt", "C:\work\" & Name & ".pdf"
With objOutLookMsg
'Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("mball@halecounty.org"
objOutLook.Recip.Type = olTo
'Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "Last test - I promise." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
'Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
'Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutLookMsg.Display
End If
Next
.Send
End With
Set objOutLookMsg = Nothing
Set objOutLook = Nothing
Exit_cmdEMailRpts_Click:
Exit Sub
Err_cmdEMailRpts_Click:
MsgBox Err.Description
Resume Exit_cmdEMailRpts_Click
End Sub
Need assistance for MS Access to Outlook XP tasks using Visual Basic....here's the problem:
Have a dBase set up that generates reports based on multiple ID's with page breaks separating the distinct records. This report is based on a CLICK event in the form's sub procedure. The form's sub CALLS the basModule that then writes the data as a .pdf file (using a standard module) and sends it to Outlook as email attachments (or so I think-cannot test it far enough to tell).
The problem arises when Outlook detects the vb script trying to access Outlook and a MsgBox (vbYesNoHelp) states: "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may.......". It does not allow me to send unsecured messages for a limited time, only allows me to CLICK the 'Yes' option twice. And, then I CLICK on a MsgBox (vbOKOnly) that states: "Object doesn't support this property or method.".
Question: What property or method is MS Access referring to? I cannot trace the code back to the debugger that is generating this error message. Also, why will MS Outlook not allow me to override the unsecured message function?
I have provided coding below for the sub procedure where the error message is occurring.
Any assistance is sincerely appreciated.
Private Sub cmdEMailRpts_Click()
On Error GoTo Err_cmdEMailRpts_Click
Dim stDocName As String
Dim Name As String
Dim objOutLook As Outlook.Application
Dim objOutLookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
'Set the Oulook session.
Set objOutLook = CreateObject("Outlook.Application"
'Create the message.
Set objOutLookMsg = objOutLook.CreateItem(olMailItem)
Call SaveReportAsPDF("rpt_ExpenseRpt", "C:\work\" & Name & ".pdf"
With objOutLookMsg
'Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("mball@halecounty.org"
objOutLook.Recip.Type = olTo
'Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "Last test - I promise." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
'Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
'Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutLookMsg.Display
End If
Next
.Send
End With
Set objOutLookMsg = Nothing
Set objOutLook = Nothing
Exit_cmdEMailRpts_Click:
Exit Sub
Err_cmdEMailRpts_Click:
MsgBox Err.Description
Resume Exit_cmdEMailRpts_Click
End Sub