S
SAm
Hi
I have been on these boards the last few days try to learn how to do this,
but i am unable.
i have successfully adapted code (thanks to the MSDN) that does exactly what
i need, e.g. send an email from microsoft access. however i get all these
warnings messages and i would like to get rid of them. i read up a lot of
postings on MSDN but i have no answers. plesae let me know what i can do
about it. i will post my code so that you can see what i am doing. btw, i am
also getting some message "type mismatch" which i can't figure out where it
comes from.
here is my code. (its on a form as a seperate subroutine)
Sub sbSendMessage(Optional AttachmentPath)
On Error GoTo Err_ErrorMsgs
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add(Me.txtEmailAddress)
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = Me.txtFacility.Column(0) & " Systems Audit " & Date
.Body = Me.txtEmailBodyText
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve each Recipient's name.
'For Each objOutlookRecip In .Recipients
'If Not objOutlookRecip.Resolve Then
'objOutlookMsg.Display
'End If
'Next
.Display
'.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
Err_ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
" Rerun the procedure and click Yes to access e-mail" & _
" addresses to send your message. For more information," & _
" see the document at http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp. "
Else
MsgBox Err.Number, Err.Description
End If
End Sub
thanks,
sam
I have been on these boards the last few days try to learn how to do this,
but i am unable.
i have successfully adapted code (thanks to the MSDN) that does exactly what
i need, e.g. send an email from microsoft access. however i get all these
warnings messages and i would like to get rid of them. i read up a lot of
postings on MSDN but i have no answers. plesae let me know what i can do
about it. i will post my code so that you can see what i am doing. btw, i am
also getting some message "type mismatch" which i can't figure out where it
comes from.
here is my code. (its on a form as a seperate subroutine)
Sub sbSendMessage(Optional AttachmentPath)
On Error GoTo Err_ErrorMsgs
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add(Me.txtEmailAddress)
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = Me.txtFacility.Column(0) & " Systems Audit " & Date
.Body = Me.txtEmailBodyText
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve each Recipient's name.
'For Each objOutlookRecip In .Recipients
'If Not objOutlookRecip.Resolve Then
'objOutlookMsg.Display
'End If
'Next
.Display
'.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
Err_ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
" Rerun the procedure and click Yes to access e-mail" & _
" addresses to send your message. For more information," & _
" see the document at http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp. "
Else
MsgBox Err.Number, Err.Description
End If
End Sub
thanks,
sam