D
Damien McBain
My excel VBA sends some files it's just created to a number of e-mail
addresses specified in one of the worksheets.
I understand why outlook warns before sending the mail from excel and other
applications, but can I stop the other message re trying to access addresses
from my adress book? The address book doen't really come into play, I have
addresses in the lists. I'm using exchange (not SMTP) so I don't think I can
use CDO.
Here's the code fwiw:
Sub EmailOutOps()
Dim objOutlook As Object
Dim objMailItem As Object
Dim objRecipient As Object
Dim objNameSpace As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
objNameSpace.Logon , , True
Set objMailItem = objOutlook.CreateItem(0)
'reference the "email" worksheet to get recipient names
For Each c In Range("emailops")
If c.Text <> "" Then
objMailItem.Recipients.Add (c.Text)
Else
Exit For
End If
Next c
'set the other mail criteria
objMailItem.Subject = "Haulage for " & Range("date")
objMailItem.Body = "File attached"
objMailItem.Attachments.Add ("I:\Accounting\Daily Tonnes\DailyReports\" &
Range("date") & "-ops.xls")
objMailItem.Send
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objMailItem = Nothing
End Sub
addresses specified in one of the worksheets.
I understand why outlook warns before sending the mail from excel and other
applications, but can I stop the other message re trying to access addresses
from my adress book? The address book doen't really come into play, I have
addresses in the lists. I'm using exchange (not SMTP) so I don't think I can
use CDO.
Here's the code fwiw:
Sub EmailOutOps()
Dim objOutlook As Object
Dim objMailItem As Object
Dim objRecipient As Object
Dim objNameSpace As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
objNameSpace.Logon , , True
Set objMailItem = objOutlook.CreateItem(0)
'reference the "email" worksheet to get recipient names
For Each c In Range("emailops")
If c.Text <> "" Then
objMailItem.Recipients.Add (c.Text)
Else
Exit For
End If
Next c
'set the other mail criteria
objMailItem.Subject = "Haulage for " & Range("date")
objMailItem.Body = "File attached"
objMailItem.Attachments.Add ("I:\Accounting\Daily Tonnes\DailyReports\" &
Range("date") & "-ops.xls")
objMailItem.Send
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objMailItem = Nothing
End Sub