Hi all,
Using Access 365.
I have a remote server where several users log into and run the Access program. All is running fine, but when the users create documents (Certificates, Test documents, Reports, etc.), the database is saving the documents to the users' folder on the local disk drive. No issue with this.
The database then uses Outlook to mail these documents to the user's E-Mail as well. I created an E-Mail on the server and the program uses the same E-Mail address to mail the documents for all users.
I found the below code in one of the forums, and seems to work fine:
BUT:Code:Public Function EmailCert(DocName As String)On Error GoTo Errh1: Dim objApp As Object Set objApp = CreateObject("Outlook.Application") Dim objNS As Object Set objNS = objApp.GetNamespace("MAPI") Dim olFolder As Object Set olFolder = objNS.GetDefaultFolder(olFolderInbox) 'Open inbox to prevent errors with security prompts olFolder.Display Dim objEmail As Outlook.MailItem Set objEmail = objApp.CreateItem(olMailItem) With objEmail .Recipients.Add MailHolder .Subject = "Certificate" .Body = "See Attached" .Attachments.Add DocName '.Display .Send End With 1 DoEvents objApp.Quit Exit Function
1. When "Set olFolder = objNS.GetDefaultFolder(olFolderInbox)" executes, an error is generated saying "Process has failed...", so I had to put this line in a remark state.
2. When there are more that 1 document mailed directly after another, only the first document is received at the recipient. No error or error messages stating that the mail was not successful, however, if I manually open Outlook on the server, the subsequent documents are sent and received.
3. I am using the "DoEvents" before closing Outlook. If I omit this line, the E-Mails are not sent.
Any suggestions to overcome?
Thanks
CS