I have automated some excel sheets to be emailed. However I get the following pop up for every email. How can I automate the "Allow" button in vba script.
***************************************
Microsoft Outlook
A program is trying to send an e-,ail message on your behalf. If this is unexpected, click Deny and verify your antivirus is up-to-date.
For more information about e-mail safety and how you might be able to avoid getting this warning, click Help.
Allow Deny Help (Buttons available in pop up)
*******************************************
Hello Try the below code:
Sub mymail()
Dim ToAddr As Variant, ccaddr As Variant, ToSubj As String, ToMsg As String
ToAddr = Join(Array("Email_ID_1", " Email_ID_2", " Email_ID_3"), "; ")
ccaddr = Join(Array("Email_ID_1", " Email_ID_2"), "; ")
ToSubj = "SOLS Report -" & Format(Date, "Long Date")
Call Send_Automatic_Email_From_Excel1(ToAddr, ccaddr, ToSubj, ToMsg)
End Sub
Sub Send_Automatic_Email_From_Excel1(ToAddr As Variant, ccaddr As Variant, ToSubj As String, ToMsg As String)
Dim oExcelEmailApp As Object
Set oExcelEmailApp = Outlook.Application.CreateItem(0)
strSignature = Environ("appdata") & _
"\Microsoft\Signatures\Local.htm"
'GET DEFAULT EMAIL SIGNATURE
Signature = Environ("appdata") & "\Microsoft\Signatures"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "*.htm")
Else:
Signature = ""
End If
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
'Signature = OtlNewMail.HTMLBody
With oExcelEmailApp
.To = ToAddr
.CC = ccaddr
.BCC = ""
.Subject = ToSubj
.HTMLBody = "Hi Team<br>PFA file for today.<br>" & Signature
'<br><p class=MsoNormal><span style='font-size:10.0pt;font-family:Times New Roman,serif;color:#1F497D'>Thanks & Regards,<br><br>" & _
"Your Name<br>Your Designation<br><br> & Signature
.Attachments.Add ThisWorkbook.FullName
.Display
End With
Set oExcelEmailApp = Nothing
End Sub
Kindly Look for the comments in the code and replace with relevant replacements plus have added your email default signatures.Hope It Works