Selasa, 01 Maret 2016

[MS_AccessPros] Access to Outlook (365) email won't send, but only for some

 

Hi,
I've got a db with some code that populates the To, From, BCC, CC, Subject line, and email body in outlook.  This code has run fine for about 5-6 years, but recently the company has upgraded email to outlook 365, and now the email addresses don't resolve when access generates the email... but only for some people. 

There are 4 users of this particular db, for 2 it resolves and sends fine, for the other 2 it doesn't (it sends but bounces back).  Up until they press the "send" button in outlook, it works the same for everyone.  We've checked access versions, office versions, mailbox permissions, network permissions, passwords, windows profiles, outlook profiles, outlook cache, etc.  I can't think of what else to check that the two people who it works for still have that the other two don't.  Is there a new way I need to code this because of office 365?  Should I late bind? (you can see i was doing that at one point because i commented out the variable type and replaced with the outlook library, I'm not sure why i switched it to the outlook library)

To make things even more strange, if the people it doesn't work for by default delete out the address that access populates, then re-enter the address themselves, it sends fine.  It's an access 03 db being run on access 07.  outlook is 365.  The "error" they get is a bounceback from exchange with the "undeliverable" message. 

I THINK it's the "from" line that's causing it, because it used to have an "&" in the address, and it had to be renamed for office 365, but that doesn't explain why it works for everyone except those 2 people after I updated the code.  I use a batch file to distribute, so everyone is using the same version of the front end. 

Thanks
-Lee

Here's the code I'm using to generate the email:

Public Sub CreateEmail(ToLine as String, CCLine as String, BCCLine as String)
Dim strHTMLBody As String
Dim appOutlook As Outlook.Application  'Object
Dim MailOutlook As Outlook.MailItem    'Object
Dim strSubject As String
Dim strFileName As String
'Dim i As Integer
'------------------------------------

On Error GoTo Oof


        strHTMLBody = "<HTML xmlns:o><HEAD><style>" _
            & "* { margin: 0; padding: 0 }" _
            & "body { font-family:Arial, Helvetica, sans-serif; }" _
            & "b { font-weight: bold;}" _
            & "span { font-weight: bold; color: Blue;}" _
            & "p { margin-bottom: 10px;}" _
            & "</style> </HEAD><BODY>" _
            & "<p>The latest blah blah blah:</p>" _
            & "<p class=MsoNormal><font size=10 face=Arial><span style='font-size:10.0pt'><a " _
            & "href=" & Chr(34) & "file:///" & Replace(DestinationFilePath, " ", "%20") & Chr(34) & ">" _
            & Left(DestinationFilePath, Len(DestinationFilePath) - 1) & "</a></span></font></p>" _
            & "</p></BODY></HTML>"
           
            strFileName = Nz(ReportName, "Summary Report")
            If InStr(1, strFileName, "Summary") = 0 Then
                strFileName = strFileName & " Summary"
            End If
            strSubject = strFileName & " is ready for review"
   
        Set appOutlook = CreateObject("Outlook.Application")
        Set MailOutlook = appOutlook.CreateItem(olMailItem)
            With MailOutlook

        .SentOnBehalfOfName = "genericmailbox@emaildomain.dot"
                .To = Nz(ToLine, "")
                .cc = Nz(CCLine, "")
                .BCC = Nz(BCCLine, "")
                .Subject = strSubject
                .HTMLBody = strHTMLBody
                .Display
                '.Attachments.Add(strTest,
            End With


Exit_CreateEmail:
    On Error GoTo 0

    Set appOutlook = Nothing
    Set MailOutlook = Nothing
Exit Sub

Oof:
    Call LogError(Err.Number, Err.Description, "CreateEmail", "mReportDistribution")
    MsgBox Err.Number & " (" & Err.Description & ")", vbCritical, "CreateEmail: Error"
    Resume Exit_CreateEmail
End Sub


__._,_.___

Posted by: leevt99@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

.

__,_._,___

Tidak ada komentar:

Poskan Komentar