Background: I manage an Access 2016 db for our local food pantry, which is staffed by (mostly senior and mostly PC-neophyte) volunteers. I mention this since my approach is to make the db interface as user-friendly as possible.
Problem: I've recently added a feature that allows our volunteers to send an email from within the db, using the pantry's default Gmail address. For example, an email to our bread supplier that we're out of stock, or to our facilities manage to report a leaky faucet. The names of possible addressees is accessed via a report (based on a query) with hyperlinked email addresses. I added vba code that works, but the email is not sent unless/until Outlook is opened outside of the db. I then added Outlook to the PC startup menu so emails would be sent out immediately. The problem is that Outlook now appears as the opening screen when Windows 10 starts up. This has annoyed/confused our users who are used to only seeing the db sign-in page.
Question: If there a way to have Outlook open and stay in minimize state, and thus be "hidden" to the user, or perhaps more elegantly, a way to add some vba code within Access that opens Outlook when the user presses the Send Email button, and then either closes or minimizes it when the current screen is closed? Here is the code I am using now for sending emails from within Access:
Private Sub Email_Click()
Dim MSG As String
MSG = "PLEASE ADD YOUR NAME TO THE BODY OF THIS EMAIL."
' Remember to add REFERENCE to Microsoft Outlook Object Library
Dim O As Outlook.Application
Dim M As Outlook.MailItem
Set O = New Outlook.Application
Set M = O.CreateItem(olMailItem)
With M
.BodyFormat = olFormatHTML
.HTMLBody = MSG
.To = Email
.Subject = "Please Help with the Following " & Now()
.Display
End With
Set M = Nothing
Set O = Nothing
End Sub
Problem: I've recently added a feature that allows our volunteers to send an email from within the db, using the pantry's default Gmail address. For example, an email to our bread supplier that we're out of stock, or to our facilities manage to report a leaky faucet. The names of possible addressees is accessed via a report (based on a query) with hyperlinked email addresses. I added vba code that works, but the email is not sent unless/until Outlook is opened outside of the db. I then added Outlook to the PC startup menu so emails would be sent out immediately. The problem is that Outlook now appears as the opening screen when Windows 10 starts up. This has annoyed/confused our users who are used to only seeing the db sign-in page.
Question: If there a way to have Outlook open and stay in minimize state, and thus be "hidden" to the user, or perhaps more elegantly, a way to add some vba code within Access that opens Outlook when the user presses the Send Email button, and then either closes or minimizes it when the current screen is closed? Here is the code I am using now for sending emails from within Access:
Private Sub Email_Click()
Dim MSG As String
MSG = "PLEASE ADD YOUR NAME TO THE BODY OF THIS EMAIL."
' Remember to add REFERENCE to Microsoft Outlook Object Library
Dim O As Outlook.Application
Dim M As Outlook.MailItem
Set O = New Outlook.Application
Set M = O.CreateItem(olMailItem)
With M
.BodyFormat = olFormatHTML
.HTMLBody = MSG
.To = Email
.Subject = "Please Help with the Following " & Now()
.Display
End With
Set M = Nothing
Set O = Nothing
End Sub