VBA microsoft security issue

MartinST

Board Regular
Joined
Jun 22, 2010
Messages
101
I have the following code that send the active workbook to several recipients, how can I overcome the security issue whereby Outlook (2003) pops up a message for the user to grant permission before sending the mail to the recipients as this message appears for each recipient in the mailing list. Is there a way to overcome this or an alternative mailing method?

Sub Create_Mail_From_List()

Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range

ActiveSheet.Unprotect
Application.ScreenUpdating = False

'Copy & Paste names for VBA to recognize the mailing list
Range("G4:I19").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("H").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "I").Value) = "yes" Then

Set OutMail = OutApp.CreateItem(0)
On Error Resume Next

With OutMail
.To = cell.Value
.Subject = "Procedure"
.Body = "Dear " & Cells(cell.Row, "G").Value _
& vbNewLine & vbNewLine & _
"Please find attached a new procedure."
.Attachments.Add ActiveWorkbook.FullName

.Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell

cleanup:
Set OutApp = Nothing

'Insert formulas again for mailing list
Range("G3:I3").Select
Selection.AutoFill Destination:=Range("G3:I19"), Type:=xlFillDefault
Range("d3").Select

Application.ScreenUpdating = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top