Solved

E-mails sent from MS Acess Application get stuck in Sent folder

Posted on 2013-01-04
5
346 Views
Last Modified: 2013-01-07
We have a function in MS Access that sends e-mails using Outlook.  This was working fine, then our company upgraded to an Outlook 2010 Exchange server.  Now this doesn't work anymore.   The e-mails are in the Sent folder, but never reach the recipients.  However, if you open the messages in the Sent folder and reply to all, they do get to the recipients.

Here is the source...


'SendMAPIEmailto replace the older one
 Public Function SendMAPIEmail(strTo As String, _
           strSubject As String, _
           strMessageBody As String, _
           Optional strAttachmentPaths As String, _
           Optional strCC As String, _
           Optional strBCC As String, _
           Optional strReplyTo As String, _
           Optional dtDTWhen As Date) As Boolean
         
   Dim mailItem As Outlook.mailItem
   Dim bSuccess As Boolean

   ' assume success but set error trap
   bSuccess = True
   lastOutlookErrorDesc = ""

 On Error GoTo SendMAPIEmail_Error

  ' if calling in a loop perhaps remove then clean, at end of loop
   InitOutlook
   If Not olApp Is Nothing Then
    Set mailItem = olApp.CreateItem(olMailItem)

    mailItem.To = strTo
    mailItem.Subject = strSubject

    ' mailItem.Display
    ' If we need HTML - we can use this:
    ' mailItem.HTMLBody = strMessageBody
    mailItem.Body = strMessageBody
   
    '------------ add all the optional items
    ' attachments
    If Not IsMissing(strAttachmentPaths) Then
     If (strAttachmentPaths <> "") Then
      Dim myAttachements As Outlook.Attachments
      Set myAttachements = mailItem.Attachments
      ' may need a little more work here
      myAttachements.Add strAttachmentPaths
     End If
    End If
    ' CC string
    If Not IsMissing(strCC) Then
     If strCC <> "" Then
      mailItem.CC = strCC
     End If
    End If
    ' BCC string
    If Not IsMissing(strBCC) Then
     mailItem.BCC = strBCC
    End If
    ' ReplyTo string
    If Not IsMissing(strReplyTo) Then
      If strReplyTo <> "" Then
        mailItem.ReplyRecipients.Add strReplyTo
      End If
    End If
    ' dtDTWhen string
    If Not IsMissing(dtDTWhen) Then
     mailItem.DeferredDeliveryTime = dtDTWhen
    End If
 '   When debugging this is useful
 '   mailItem.Display

    mailItem.Send

'    GoTo EndSend
   End If

SendMAPIEmail_Exit:
 ' clean up and exit
   CleanUp
   SendMAPIEmail = bSuccess
   On Error GoTo 0
   Exit Function

 ' if we get here then something wne wrong
SendMAPIEmail_Error:
   bSuccess = False
   lastOutlookErrorDesc = Err.DESCRIPTION
   Resume SendMAPIEmail_Exit

 End Function
0
Comment
Question by:jribble
  • 2
  • 2
5 Comments
 
LVL 57
ID: 38746647
Sounds like the problem is in Exchange.  I would look at the message tracking to see what the issue is.

If it's in the "sent" folder, Outlook considers it sent.

Jim.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 38751053
Try commenting out the all the code regarding "dtDTWhen"
Not sure why it is needed, but it seems to have something to do with "sending" the email, ...this would be a good place to start your investigation.
0
 
LVL 57
ID: 38751071
I missed that; good catch!

Jim.
0
 

Author Closing Comment

by:jribble
ID: 38751500
Removing the dtDTWhen related statments solved the problem.  E-mails are now coming through to my Inbox.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38751691
Great,

Again, that was just a shot in the dark...
;-)

As I stated, I was not sure what that was, or why it was needed...

Furthermore, I am not sure why it may have worked before, but does not work now...
(I'm no Exchange Expert...)

;-)


Jeff
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AD and Exchnage 2010 Photos 3 42
SharePoint 2013 URL Duplication Issue 5 25
File.Search issue 8 33
Signature required on a report 5 33
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question