Hi all,
I have written the code below so that if a value in a specific cell is greater than value 25 when workbook is closed, I automatically receive an e-mail with body "Content is changed". Code is working perfectly, however a pop-up appears with a loading bar. As soon as this bar is loaded, you need to click on "Allow" to send this mail, if someone press on "Deny", the mail will not be send out.
Therefore I am searching for a solution to avoid this pop-up or include the following (wait until loading bar is loaded + click "Allow") is integrated in the code.
I have used the function "Help", they suggest to adjust the Outlook options in MS Outlook -> Trust Center -> Trust Center settings -> Programmatic Access. However as this code is working from a Microsoft Exchange Server, I am not able to change this option.
Code:
This Workbook:
Private Sub Workbook_Open()
Call Macro_Test
End Sub
Private Sub Workbook_Deactivate()
Call Macro_Run
End Sub
Module1:
Public inhoud1 As String
Public inhoud2 As String
Sub Macro_Test()
inhoud1 = Range("C13")
End Sub
Sub Macro_Run()
inhoud2 = Range("C13")
If Not inhoud2 = inhoud1 Then
If inhoud2 > 25 Then
'Start Mailing
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "e-mail adress"
.CC = ""
.BCC = ""
.Subject = "Subject"
.Body = "Content is changed"
.Attachments.Add Order.FullName
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
'Range("A1").Value = "Mail is gestuurd"
'End mailing
Else: Exit Sub
End If
End If
End Sub
I would like to thank you in advance to help me in achieving constructing this code.
Kind regards,
Jeffrey
Bookmarks