bobsg
Posts: 1
Joined: 2012-01-31
|
I am using the following VBA code to send this workbook as an attacment to an email using Outlook. I am still gettng outlook warning. I am using similar code in MS access and the security popup is being successfully suppressed
Dim SecurityManager As Object
Set SecurityManager = CreateObject("AddInExpress.OutlookSecurityManager")
SecurityManager.DisableSMAPIWarnings = True
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "mmddyy")
Application.ScreenUpdating = False
Sheets("Sheet2").Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Stock_Status_010_" & strdate & ".xlsx"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "bob@cga-cpa.com"
.CC = ""
.BCC = ""
.Subject = "Stock Status 010 " & Format(Date, "MM/dd/YY")
.Body = "Attached is the Stock status report for BI."
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
SecurityManager.DisableSMAPIWarnings = False
Set SecurityManager = Nothing |
|
Renat Tlebaldziyeu
Guest
|
Hello,
What version (with build number, please) of Outlook Security Manager do you use?
I recommend you to install the latest version of Security Manager ActiveX (6.2.1030), you can download it from our web-site. Here is the download page:
http://www.add-in-express.com/downloads/osm.php
Please note that you should disable OOM security warnings as you use the objects provided by the Outlook object model. Here is the code:
Dim SecurityManager As Object
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "mmddyy")
Application.ScreenUpdating = False
Sheets("Sheet2").Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Stock_Status_010_" & strdate & ".xlsx"
Set OutApp = CreateObject("Outlook.Application")
Set SecurityManager = CreateObject("AddInExpress.OutlookSecurityManager")
SecurityManager.ConnectTo(OutApp)
SecurityManager.DisableOOMWarnings = True
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "bob@cga-cpa.com"
.CC = ""
.BCC = ""
.Subject = "Stock Status 010 " & Format(Date, "MM/dd/YY")
.Body = "Attached is the Stock status report for BI."
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C: est.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
SecurityManager.DisableOOMWarnings = False
SecurityManager.Disconnect(OutApp)
Set SecurityManager = Nothing
Do you get security warnings if you use this code? |
|