E
ericb
I have this odd problem.
When I run this function from within Access everything is fine.
Public Function sendEmail(strTo As String, _
strCC As String, _
strBCC As String, _
strSubject As String, _
strMessageBody As String, _
strAttachments As String) As Boolean
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler
Const errUserDeny As Long = 287 ' Un numéro d'erreur Ã
trapper
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim TempArray() As String
Dim varArrayItem As Variant
Dim strAttachmentPath As String
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = strTo
.Subject = strSubject
.Body = strMessageBody
' Ajoute les Attachments
If Len(strAttachments) > 0 Then
TempArray = Split(strAttachments, ";")
For Each varArrayItem In TempArray
strAttachmentPath = Trim(varArrayItem)
If Len(strAttachmentPath) > 0 Then
.Attachments.Add strAttachmentPath
End If
Next varArrayItem
Else
.Attachments.Add ""
End If
.Send
'.ReadReceiptRequested
End With
Exit_Here:
Set objOutlook = Nothing
sendEmail = True
Exit Function
Error_Handler:
If (Err <> errUserDeny) Then
MsgBox Err & ": " & Err.description
End If
Set objOutlook = Nothing
sendEmail = False
'Resume Exit_Here
End Function
At other points in the database I use the function docmd.sendobject ... and
everything is ok.
But when I put the database in a Package using Developper Package Solution
and run the code I get the Error Number: 3326 message.
This happens only when I use the function sendEmail. It is Ok when I run the
docmd.sendobject...
Can someone tell me where I am going wrong ?
Thank you
When I run this function from within Access everything is fine.
Public Function sendEmail(strTo As String, _
strCC As String, _
strBCC As String, _
strSubject As String, _
strMessageBody As String, _
strAttachments As String) As Boolean
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler
Const errUserDeny As Long = 287 ' Un numéro d'erreur Ã
trapper
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim TempArray() As String
Dim varArrayItem As Variant
Dim strAttachmentPath As String
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = strTo
.Subject = strSubject
.Body = strMessageBody
' Ajoute les Attachments
If Len(strAttachments) > 0 Then
TempArray = Split(strAttachments, ";")
For Each varArrayItem In TempArray
strAttachmentPath = Trim(varArrayItem)
If Len(strAttachmentPath) > 0 Then
.Attachments.Add strAttachmentPath
End If
Next varArrayItem
Else
.Attachments.Add ""
End If
.Send
'.ReadReceiptRequested
End With
Exit_Here:
Set objOutlook = Nothing
sendEmail = True
Exit Function
Error_Handler:
If (Err <> errUserDeny) Then
MsgBox Err & ": " & Err.description
End If
Set objOutlook = Nothing
sendEmail = False
'Resume Exit_Here
End Function
At other points in the database I use the function docmd.sendobject ... and
everything is ok.
But when I put the database in a Package using Developper Package Solution
and run the code I get the Error Number: 3326 message.
This happens only when I use the function sendEmail. It is Ok when I run the
docmd.sendobject...
Can someone tell me where I am going wrong ?
Thank you