PC Review


Reply
 
 
Filips Benoit
Guest
Posts: n/a
 
      5th Feb 2010
Dear All,

Since 2 months we use CDO to send emails using function below.
All is Ok but occasionally emails are NOT send without any error-message.
For that reason i inserted a check ( AddEmail2Log and DoCmd.RunSQL ...) to
log emailsending and store success or failure.
Since insert log i haven't seen any failure.

But maybe you can see a week point in my code !
Maybe there is a better newsgroup to ask this question but i can't find it.

thanks,

Filip

-------------------------------------------------------------------------------------------------------------------------------
Public Function SendCDOemail(Optional ToAddres As Variant, Optional
FromAddres As Variant, _
Optional CCAddres As Variant, Optional Subject As Variant, _
Optional MessageText As Variant, Optional Attachment1Path As Variant,
Optional strFromForm As Variant) As Boolean
' set references to Microsoft Scripting Runtime AND Microsoft Office
12.0 Object Library
On Error GoTo ErrorMsgs

Dim iNewEmailLogID As Long
Dim objMessage As Object
Set objMessage = CreateObject("CDO.Message")
SendCDOemail = False

'store email attempt in log
iNewEmailLogID = AddEmail2Log(Now(), strFromForm, "CDO", False,
ToAddres, "", "", "", "", "")

If Not IsMissing(ToAddres) Then
objMessage.To = ToAddres
End If
If Not IsMissing(FromAddres) Then
objMessage.FROM = FromAddres
End If
If Not IsMissing(CCAddres) Then
objMessage.CC = CCAddres
End If
If Not IsMissing(Subject) Then
objMessage.Subject = Subject
End If
If Not IsMissing(MessageText) Then
objMessage.TextBody = MessageText
End If
If Not IsMissing(Attachment1Path) Then
objMessage.AddAttachment Attachment1Path
End If

objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "uit.telenet.be"
objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
objMessage.Configuration.Fields.Update
objMessage.Send
Set objMessage = Nothing

SendCDOemail = True

' note success
DoCmd.RunSQL "UPDATE TBL_EMAIL_LOG SET TBL_EMAIL_LOG.EMAIL_SEND_OK =
True WHERE (((TBL_EMAIL_LOG.EMAIL_SEND_ID)=" & iNewEmailLogID & "));"


Exit Function

ErrorMsgs:
MsgBox "SendCDOemail" & Chr(13) & Err.Number & " " & Err.Description
SendCDOemail = False
End Function


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to forward a template email with an email address contained inthe trigger email Casey Sheldon Microsoft Outlook VBA Programming 1 1st Nov 2010 02:08 PM
white out and lost email when sending long email (to same email ad rluchansky Windows Vista Mail 0 13th Mar 2010 04:30 PM
Attach an old email to new email when using Word 2003 email editor =?Utf-8?B?TWVs?= Microsoft Outlook Discussion 2 2nd Feb 2007 04:36 PM
how can I convert an email attached to an email back to email ale =?Utf-8?B?dGxlZQ==?= Microsoft Outlook Discussion 0 28th Mar 2006 11:26 PM
Client Table with Email? Click email address to send email? =?Utf-8?B?QnJvb2s=?= Microsoft Access Forms 0 10th Aug 2005 05:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:16 PM.