Kamis, 23 Agustus 2018

[MS_AccessPros] Re: outlook does not recognize one or more names

 

Hi Kat


This might just be a bug in 2016. I don't have that version so I can't test it. Something I'd like to suggest to see if it helps...

You are dimming the Outlook objects with each email. This is using more resources than need be. Change you code so the re-usable ones are only dimmed once and released when the loop is finished. 

My changes would look like this:


Private Sub RUN_Click()
'You didn't Dim your DAO objects
    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    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")


    ' Open a recordset on the expiring contracts
    Set db = CurrentDb
    Set rst = db.OpenRecordset("SELECT * FROM [INS TBL] WHERE [SEND EMAIL] = True")
    ' Loop through them all
    Do Until rst.EOF
        ' Make sure we have a valid email
        If Not IsNull(rst![VENDOR E-MAIL]) Then
            ' Create the message.
            Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

            With objOutlookMsg
                ' Add the To recipient(s) to the message.
                Set objOutlookRecip = .Recipients.Add(rst![VENDOR E-MAIL])
                objOutlookRecip.Type = olTo

                ' Add the CC recipient(s) to the message.
                Set objOutlookRecip = .Recipients.Add(rst![E-MAIL])
                objOutlookRecip.Type = olCC

                ' Add the BCC recipient(s) to the message.
                Set objOutlookRecip = .Recipients.Add(rst![FINANCE EMAIL])
                objOutlookRecip.Type = olBCC

                ' Set the Subject, Body, and Importance of the message.
                .Subject = "Certificate of Insurance Expire Date Approaching"
                .Body = "ATTN: " & " " & rst![CONTACT PERSON] & " " & _
                        "-" & vbCrLf & vbCrLf & "Please be advised that the Certificate of Insurance for " & _
                        "" & rst![VENDOR NAME] & " has expired or will expire on " & _
                        rst![CERTIFICATE EXPIRATION DATE] & _
                        "." & vbCrLf & vbCrLf & "Please submit renewed Certificate of Insurance as soon as possible.  " & _
                        "If you have any questions, please contact me.  Your cooperation is greatly appreciated." & _
                        vbCrLf & vbCrLf & "Thank you." & vbCrLf & vbCrLf
                .Importance = olImportanceHigh    'High importance

                ' Resolve each Recipient's name.
                For Each objOutlookRecip In .Recipients
                    objOutlookRecip.Resolve
                Next

                ' Should we display the message before sending?
                If DisplayMsg Then
                    .Display
                Else
                    .Save

                    .Send
                End If
            End With
        End If
        ' Get the next one
        rst.MoveNext
    Loop
    
    ' Close out
    Set objOutlook = Nothing
    rst.Close
    Set rst = Nothing
    Set db = Nothing
    
End Sub

That probably won't solve your issue but it will make you code more efficient. If the issue is a show-stopper I recommend purchasing vbMAPI from everythingAccess.com It is by far the best solution for Outlook Automation. The tutorials are amazingly complete and you don't need to install anything on the user's computer. You just add the vbMAPI classes to your project by using the add-in. It just might make your code get past that bug.

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com

 


---In MS_Access_Professionals@yahoogroups.com, <no_reply@yahoogroups.com> wrote :

It is pointing to the Microsoft Outlook 16.0 Object Library.  I have no problems sending emails to regular email addresses, but if the email address contains a "." in it, it will not send the email, instead it places the email in the draft box in outlook, and then I can send from there, but it does not automatically send it like it did before.

__._,_.___

Posted by: wrmosca@comcast.net
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar