Sending email with attachment using Sendobject & Thunderbird client

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ACB64
    New Member
    • Oct 2021
    • 16

    Sending email with attachment using Sendobject & Thunderbird client

    Hi. I'm running win 10 (updated to most recent).
    I've recently rebuilt my computer and have reinstalled Access 2007 and a split database. In the front-end there is a script to email a message to multiple recipients. I select the recipients from a list and click a "send" button, intending to send it as an email in Thunderbird. I'm using the standard Sendobject code.
    It used to work and now doesn't. The same database is used on another computer (both front-end and back-end are on a cloud drive) without problems. I get the message:
    "Runtime error 2046:
    The command or action SendObject isn't available now."
    I have spent days looking for a solution.
    Can anyone help?
    Thanks in advance.


    Full code of subroutine follows. Note that in the following there is a function called ConcatRelated. It works to create a string of email recipients. It definitely works:
    Code:
    Private Sub Command76_Click()
    'Check for empty Subject line
    If IsNull(Text89) Then
        MsgBox "Please enter some text for the SUBJECT.", vbOKOnly, "Error"
        Text89.SetFocus
        Exit Sub
    End If
    'Check for empty text
    If IsNull(Text73) Then
        MsgBox "Please enter some text for the MESSAGE.", vbOKOnly, "Error"
        Text73.SetFocus
        Exit Sub
    End If
    
    'Determine the recipients to be sent an email
    Dim varItem As Variant
    Dim recipients As String
    'Determine if at least one course has been selected
    If List77.ItemsSelected.Count = 0 Then
        MsgBox "Please select at least one course", vbOKOnly, "Error"
        Exit Sub
    End If
    'Collect email addresses of the recipients
    recipients = ""
    
    Lc = List77.ListCount
    
    'If "ALL" is selected, then select all courses
    If List77.Selected(1) Then
        Dim i As Integer
        For i = 0 To List77.ListCount - 1
        List77.Selected(i) = True
        Next i
    End If
         
            'loop through all selected courses
                Dim z As Long
                With List77
                
                    For z = 2 To Lc
                      If List77.Selected(z) Then
                        If Check81 Then recipients = ConcatRelated("Invoicemail", "BulkEmail", "[coursekey]= """ & .ItemData(z) & """", , ";") & recipients 'Email invoicees
                        If Check79 Then recipients = ConcatRelated("StudentEmail", "BulkEmail", "[coursekey]= """ & .ItemData(z) & """", , ";") & recipients  'Email Students
                     End If
                    Next z
                End With
    
        'remove duplicates
        recipients = EliminateDupesInString(recipients, ";")
        ' Calculate number of email addresses
        If recipients <> "" Then x = Len(recipients) - Len(Replace(recipients, ";", ""))
        MsgBox "There are " & Str(x) & " addresses."
    
        If recipients <> "" Then DoCmd.SendObject acSendNoObject, , acFormatRTF, "office@xxx.com", , recipients, Text89, Text73, True
        DoCmd.Close
    End Sub
    Last edited by NeoPa; Oct 26 '21, 12:56 AM. Reason: Added mandatory [CODE] tags.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    Have you tried to Dubug (Debugging in VBA) this code and seen what each variable holds at the time you get the error (Line #54) in your code?

    Comment

    • ACB64
      New Member
      • Oct 2021
      • 16

      #3
      Hi NeoPa,
      Thanks for answering. Yes, I have and everything checks out. The error appears only when the SendObject is attempted. All variables are valid. Also, it works on another machine, and also worked seamlessly prior to the rebuild.
      I remember having this issue about 1 year ago and I found a solution, but have no idea what it was. How silly that I didn’t record the solution.
      ACB

      Comment

      • GazMathias
        Recognized Expert New Member
        • Oct 2008
        • 228

        #4
        Hi ACB64,

        Doesn't SendObject negotiate with the default mail client? That would suggest that the problem seems to be outside of your Access solution. I do not use Thunderbird, but is there a setting for enabling this kind of automation?

        Gaz

        Comment

        • ACB64
          New Member
          • Oct 2021
          • 16

          #5
          Hi Gaz,
          Yes, that’s my understanding, and exactly the reason for my problem. Previously, I had no problems with SendObject negotiating with Thunderbird. Now, however, after the rebuild, something is presumably different and I don’t know what it is.
          Andrew.

          Comment

          • ACB64
            New Member
            • Oct 2021
            • 16

            #6
            Hi Mycinegisters,
            Any hints??? I checked out your blogs and didn’t find anything that looked related to my issue.
            Andrew.

            Comment

            • GazMathias
              Recognized Expert New Member
              • Oct 2008
              • 228

              #7
              Hi ACB64,

              In Windows itself, when you right click a file and select Send To... Mail recipient does Thunderbird respond properly?

              Is Thunderbird defined as the default mail handler in PC Settings -> Default apps?

              Is the build of Thunderbird the same on your machine and the working machine, and are you able to directly compare settings?

              Gaz

              Comment

              • GazMathias
                Recognized Expert New Member
                • Oct 2008
                • 228

                #8
                Hi ACB64,

                In addition to my prior questions I also meant to ask if both Office and Thunderbird are targetting the same architecture (x86 / x64)?

                Gaz

                Comment

                • ACB64
                  New Member
                  • Oct 2021
                  • 16

                  #9
                  Hi Gaz,
                  Thanks for responding so quickly.
                  Yes, TB is the default email client in Windows.
                  Yes, the machine computer aus running TB 32 Bit and Access 2007 only had the 32 Bit architecture. I tried running the 64 Bit version of TB, but got the same problem. Then I went back to the 32 Bit Version of TB. The two machines are similar except the „working“machin e is running office 2013 and the corresponding version of Outlook. I even tried installing the Access 2013 runtime and ran the DB with that. No help. The problem was still there. I uninstalled the runtime. Apart from that, I can no differences. However, as stated previously, the “non working” machine used to work and the build is, as far as I can tell, the same a as before (Win 10, access 2007, TB, etc.)
                  Andrew.

                  Comment

                  • GazMathias
                    Recognized Expert New Member
                    • Oct 2008
                    • 228

                    #10
                    Hi Andrew,

                    Did the right click file -> Send To -> Mail recipient test work?

                    I assume the machine has been restarted since the reinstallation of Thunderbird? Shutdown / cold boot does not count (Win 10 fast boot shenanigans).

                    Gaz

                    Comment

                    • ACB64
                      New Member
                      • Oct 2021
                      • 16

                      #11
                      Hi Gaz,
                      Sorry, I completely missed that one. I just tried right-click/send to (mail) and … it didnt work. I checked to see what the default email client is, and it lists TB. Strange!!
                      And, yes, the machine has been restarted many times. I rebuilt it about 3 weeks ago and have been trying to solve this ever since🤔.
                      What do you think?
                      Andrew.

                      Comment

                      • ACB64
                        New Member
                        • Oct 2021
                        • 16

                        #12
                        Oh, one more thing…

                        Originally posted by ACB64
                        Hi Gaz,
                        Sorry, I completely missed that one. I just tried right-click/send to (mail) and … it didnt work. I checked to see what the default email client is, and it lists TB. Strange!!
                        And, yes, the machine has been restarted many times. I rebuilt it about 3 weeks ago and have been trying to solve this ever since🤔.
                        What do you think?
                        Andrew.
                        When I try to right click and send as email, the message I get is “these files can’t be emailed because there is no email program on this computer install an email program and try again”. But, as I said, Thunderbird is installed and TB is listed as the default email client.

                        Comment

                        • GazMathias
                          Recognized Expert New Member
                          • Oct 2008
                          • 228

                          #13
                          Hi Andrew,

                          I suspected as much.

                          Thunderbird FAQs say to reinstall the client and it should put all the MAPI settings back but you say you've allready done that.

                          One very simple thing you can try is to change the Default app Email setting back to Windows Mail, reboot and then change it back to Thunderbird. It might convince Windows to recreate the correct MAPI settings.

                          If that does not work then the settings that tell Windows how this should work are located inside HKLM -> SOFTWARE -> Mail but correcting those entries is beyond the scope of what we can do here and you must realise that incorrect registry modifications can lead to serious corruption and we can take no responsibility for any damage done to your Windows installation.

                          The best course of action I would then suggest is to contact Thunderbird support as it is very much a Thunderbird issue.

                          If you are no stranger to the registry and you have a good and valid backup of your old Windows partition that you can browse (or better, virtualise and boot) then I would suggest that you extract its registry hive and inspect your old settings to compare them, but be aware of any potential valid differences, such as different versions of referenced items / paths.

                          I feel that the solution is in reach but as mentioned, it has gone beyond the scope of what we can do for you now.

                          Gaz

                          P.S. Sorry for the delay, I have slept since we last corresponded / other IRL distractions.

                          Comment

                          • ACB64
                            New Member
                            • Oct 2021
                            • 16

                            #14
                            Hi Gaz,
                            Thanks. We all have to sleep! After my last response, I followed directions to modify the registry and succeeded in getting the right click action to work. However, still no joy in finding a solution to the original problem.
                            While dwelling on the issue whilst trying to sleep, I remembered that when I had this problem years ago, I added some object library to access (via the VBA-tools menu) and I think that was the solution. I have no idea which library/ libraries I added though. Have you any ideas? I spent some time this morning searching, but found nothing helpful.
                            Cheers.

                            Comment

                            • GazMathias
                              Recognized Expert New Member
                              • Oct 2008
                              • 228

                              #15
                              Hi Andrew,

                              I don't know what to tell you.

                              A quick n dirty SendObject test worked for me using the 365 version of Outlook O2K16 on Windows 10 21H1 and I had to set no additional references to do so.

                              Admittedly, I do not use SendObject (or MAPI in general) as our projects usually dictate Outlook automation or SMTP connections to Microsoft Exchange servers over SSL in .NET land.

                              If I were confronted with this problem at this stage I would first see if the problem can be replicated on another machine and use forensic techniques to discover what file / reg queries the call to SendObject generates versus a working instance.

                              I still think something is awry with the registry and that Thunderbird support may be your best course of action, as it may well be a known issue to them.

                              There are other MAPI-based mail sending options but they would obviously involve refactoring your solution.

                              Gaz

                              Comment

                              Working...