Send Email from VBA
Original Code: (Thx Bob Phillips):
How do I get rid of the security prompt? (it comes up two times?).
'======
Private Sub CommandButton2_Click()
Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim oNameSpace As Object
Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNameSpace("MAPI")
oNameSpace.Logon , , True
Set oMailItem = oOutlook.CreateItem(0)
Set oRecipient = _
om")
oRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these lines with
'your names, adding to the collection.
With oMailItem
.Subject = "This is an automatic email notification: Bad Link
from SPEC INDEX Excel File!"
.body = "(Please enter the ""Spec Name"", ""Worksheet Name"" and
""Cell Address"" and a brief description of the problem!)"
' .Attachments.Add ("filename") 'you only need this if
'you are sending attachments?
.Display 'use .Send when all testing done
End With
Set oRecipient = Nothing
Set oMailItem = Nothing
Set oNameSpace = Nothing
Set oOutlook = Nothing
End Sub
'======
--
Regards
VBA.Noob.Confused
XP Pro
Office 2007
"Rick S." wrote:
How or can I setup the body of an email to have more than one line?
Can I open a template? How?
'======
With oMailItem
.Subject = "The extract has finished."
.Body = "This is an automatic email notification"
'======
--
Regards
VBA.Noob.Confused
XP Pro
Office 2007
|