03Explorer
Technical User
[Bold]I know the title sounds very suspicious and the feature is valid for protection, but I need to bypass it for my internal app so the system can send team members emails with generated attachments.[/bold]
I am using Office 365, I am building an app in Access that processes data, then attaches an Excel file to an email. All is working except for the send email. It prompts the user with "A program is trying to send an email message on your behalf. If this is unexpected, click Deny and verify your antivirus software is up-to-date." ... prompt waiting for [BOLD]Allow/Deny button[/bold] to continue processing.
I am using Office 365, I am building an app in Access that processes data, then attaches an Excel file to an email. All is working except for the send email. It prompts the user with "A program is trying to send an email message on your behalf. If this is unexpected, click Deny and verify your antivirus software is up-to-date." ... prompt waiting for [BOLD]Allow/Deny button[/bold] to continue processing.
Code:
Sub SendEmail(DirLocation)
Dim appOutLook As Outlook.Application '- Outlook Application
Dim MailOutLook As Outlook.MailItem '- Outlook Mail
Dim objFSO As Object '- File System Object
Dim objFolder As Object '- Folder
Dim objFile As Object '- File
Dim strFldr As String '- Folder Name
Dim strNme As String '- Original File Name
Dim strPth As String '- Original File Path
Dim strDpth As String '- Destination File Path
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFldr)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.createitem(olMailItem)
Set db = CurrentDb
Set objFolder = objFSO.GetFolder(strFldr)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.createitem(olMailItem)
Set db = CurrentDb
strFldr = DirLocation
strNme = objFile.Name '--file name
If strNme <> "" Then
Set MailOutLook = appOutLook.createitem(olMailItem) '-- Intiate Outlook to create a new email message
With MailOutLook '-- Define and populate Email message
.Display
.BodyFormat = olFormatRichText
.To = "RobertWagner@SullivanCotter.com" '-- Testing purposes
.Subject = "Subject text here"
.HTMLBody = "Body text here"
.Attachments.Add strPth & strNme '-- Attachment #1 (File)
'- I want to understand options for .SendUsingAccount for speicific vs a Number(3)
.SendUsingAccount = appOutLook.Session.Accounts.Item(3) '- third associated email address
.Send
End With
Else
MsgBox "No file matching " & strPth & strNme & " found." & vbCrLf & _
"Processing terminated."
Exit Sub 'This line only required if more code past End If
End If
End Sub