L
LA Lawyer
I am trying to use Access 2007 to send an email through Outlook 2007.
Everything works until Outlooks pops the security warning. How do get
Outlook to stop this?
Here is my code, which otherwise is fine:
Public Function SendEMail(Receipient As String, theSubject As String,
theBody As String, Optional CarbonCopy As String, Optional BlindCopy As
String)
Dim nsMAPI As Outlook.NameSpace
Dim objOutbox As Outlook.MAPIFolder
Dim objNewMessage As Outlook.MailItem
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
If objOutlook Is Nothing Then
Set objOutlook = New Outlook.Application
End If
Set nsMAPI = objOutlook.GetNamespace("MAPI")
Set objOutbox = nsMAPI.GetDefaultFolder(olFolderOutbox)
Set objNewMessage = objOutbox.Items.Add
With objNewMessage
.To = Receipient
.Body = theBody
.Subject = theSubject
If Not IsNull(CarbonCopy) Then
.cc = CarbonCopy
End If
If Not IsNull(BlindCopy) Then
.BCC = BCC
End If
.Send
End With
End Function
Everything works until Outlooks pops the security warning. How do get
Outlook to stop this?
Here is my code, which otherwise is fine:
Public Function SendEMail(Receipient As String, theSubject As String,
theBody As String, Optional CarbonCopy As String, Optional BlindCopy As
String)
Dim nsMAPI As Outlook.NameSpace
Dim objOutbox As Outlook.MAPIFolder
Dim objNewMessage As Outlook.MailItem
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
If objOutlook Is Nothing Then
Set objOutlook = New Outlook.Application
End If
Set nsMAPI = objOutlook.GetNamespace("MAPI")
Set objOutbox = nsMAPI.GetDefaultFolder(olFolderOutbox)
Set objNewMessage = objOutbox.Items.Add
With objNewMessage
.To = Receipient
.Body = theBody
.Subject = theSubject
If Not IsNull(CarbonCopy) Then
.cc = CarbonCopy
End If
If Not IsNull(BlindCopy) Then
.BCC = BCC
End If
.Send
End With
End Function