Hi,
I have a list of email addresses on an Excel document. When I try to send an email with an attachment (using a macro programme there are normally 10 emails each with an attachment sent one after another) I encounter the following warning message before each email will send:
A programme is automatically trying to send an email on your behalf.
Do you want to allow this?
If this is unexpected, it may be a virus and you should choose "no".
Does anyone know how to overcome the security - I am using MS Windows OUTLOOK 2003. I think it has something to do with inserting SEND KEYS...(but I don't know where to insert these)
I would appreciate any help at all.....Many thanks
The code I am using so far is...
Sub emailgood()
'
' emailgood Macro
' Macro recorded 21/08/2007 by david.wilson
'
Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim cell As Range, FileCell As Range, rng As Range
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set sh = Sheets("Sheet1")
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConstants)
Set rng = sh.Cells(cell.Row, 1).Range("C1:z1")
If cell.Value Like "?*@?*.?*" And _
Application.WorksheetFunction.CountA(rng) > 0 Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = cell.Value
.Subject = "AGED DEBTORS week ending Friday 5th November 2010 : Within Terms vs Overdue Invoices"
.Body = "This is an automated email message:" & vbNewLine & _
"" & vbNewLine & _
"Hello," & vbNewLine & _
"" & vbNewLine & _
"This email is automatically sent XYZ happens" & vbNewLine & _
"" & vbNewLine & _
"The email subject and the attached file have the same unique date and time for ease of identification." & vbNewLine & _
"You may want to create a Folder on your desktop in which to store these attachments." & vbNewLine & _
"Alternatively you can create a Rule within Outlook to save these emails to a Folder within your Inbox." & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & _
"If you require anymore information either within this email or in the attached file," & vbNewLine & _
"then contact the sender of the file." & vbNewLine & _
"" & vbNewLine & _
"End of message"
For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
If Trim(FileCell) <> "" Then
If Dir(FileCell.Value) <> "" Then
.Attachments.Add FileCell.Value
End If
End If
Next FileCell
.Send
End With
Set OutMail = Nothing
End If
Next cell
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
'
End Sub