Results 1 to 12 of 12
  1. #1
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150

    Send mail from outlook not working after Win10 upgrade

    Hello,

    I have code that in win7 successfully automated sending emails to recipients. I've recently upgraded to win10 and this code has stopped working. It errors on the link .send with the error "Runtime error '287': Application defined or object defined error".

    I think this could be because the .to and .cc fields are not set but I'm not sure. When I look in the locals window, you can see that the .cc .to (not in attached screenshot) and .htmlbody fields are not set even though they are defined in the code. My code is below with the set defining "text" slightly edited because it is long and boring in the original.

    I've done a bit of a google and it appears that I'm not the only one with this problem, but I wasn't quite able to ascertain what to do from my search results so thought I would ask here.

    Code:
    Set reviewList = CurrentDb.OpenRecordset("SELECT * FROM tblIPScomments WHERE [Plan]=" & Me.txtHiddenID & " AND isnull([EmailSent])")
        Set Plan = CurrentDb.OpenRecordset("SELECT * FROM tblIPS WHERE [ID]=" & Me.txtHiddenID)
        Set oApp = CreateObject("Outlook.Application")
               
        ' Loop through the recordset and email the reviewers about their responsibilities
        If reviewList.BOF And reviewList.EOF Then
            ' Request for review emails already sent, inform the user and exit
            text = "Request for review emails have already been sent for this plan."
            MsgBox text, vbOKOnly, "Duplicated Action"
            Exit Sub
        End If
        reviewList.MoveFirst
        Do Until reviewList.EOF
       
            ' First process any Main reviewers.  We have already checked that these are always specified
            ' EMAIL TEXT
           
            ' Line 1:  Warning that this is an automated email and not to reply to it.  This is always the same
            text = "Long and boring section setting up the body of the email. Removed"
           
            ' END EMAIL TEXT
            
            'Send the email
            Set oMail = oApp.CreateItem(olMailItem)
     
          '  On Error Resume Next
            With oMail
                .To = DLookup("[email]", "tblUsers", "[ID]=" & reviewList("MainReviewer"))
                .cc = DLookup("[email]", "tblUsers", "[ID]=" & reviewList("BackupReviewer"))
                .BCC = ""
                .subject = "Please Review IPS Plan " & Plan("WorkPlan") & " by " & reviewList("DueDate")
                ' If High Urgency is set, send as important
                If Me.chkUrgency Then .Importance = olImportanceHigh
                .HTMLBody = text
                .Send             ' <- ERRORS HERE
            End With
            On Error GoTo 0
     
            ' Mark the email as having been sent
            reviewList.Edit
            reviewList("EmailSent") = Now
            reviewList.Update
                   
            ' Move to the next reviewer
            reviewList.MoveNext
           
        Loop
     
        Set oMail = Nothing
        Set oApp = Nothing

    Attached Thumbnails Attached Thumbnails LocalsWindow.png  

  2. #2
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Click image for larger version. 

Name:	LocalsWindow.png 
Views:	28 
Size:	154.9 KB 
ID:	43536
    Now with attachement

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Check your references.

  4. #4
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    See attached, they look okay to me
    Click image for larger version. 

Name:	References.png 
Views:	28 
Size:	144.8 KB 
ID:	43537

  5. #5
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    1. Have you try the .Display instead of .Send to see if keep throws the error?

    2. Someone said that solved it by making a minor delay (1 sec) before the .Send command.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Is Exchange involved in any way? Is Windows reporting that antivirus is on?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Yes, they look firn to me as well.
    I'd go back to the code and walk through it with F8.

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Assign your emails to string variables outside and before you get involved with the Outlook methods and properties.
    Then use the variable in the Outlook section.

    At some point VBA or Outlook got fussy about this for some reason.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Quote Originally Posted by accesstos View Post
    1. Have you try the .Display instead of .Send to see if keep throws the error?

    2. Someone said that solved it by making a minor delay (1 sec) before the .Send command.
    Okay so .display works just fine and everything is populated as expected, it's just .send that doesn't work. Stepping through it with F8 doesn't make any difference so I doubt a delay will help.

    Hmm, progress though

  10. #10
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    I bet I know what it is. We have a new thing where we have to have a security setting set on all emails. Does that sound like the type of thing that could be preventing sending. If so any idea how I do that programmatically?

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    There used to be a warning along the lines of 'A program is attempting to send an email' ?, but I have not see that warning for ages, and cannot even remember what I did.

    Have a look here perhaps?, or ask your IT dept?

    https://www.google.com/search?q=a+pr...hrome&ie=UTF-8

  12. #12
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I believe the warning no longer shows if there is an active antivirus running and it reports correctly to Windows security that is "on" hence my earlier question.
    Robyn, maybe you could try using CDO to send the emails instead Outlook automation or try to use Dimitri's Outlook Redemption (http://www.dimastr.com/redemption/home.htm), I used to use it with great success in the past.

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 07-12-2018, 05:38 AM
  2. Replies: 3
    Last Post: 08-17-2016, 08:26 AM
  3. Replies: 7
    Last Post: 11-24-2015, 12:42 PM
  4. Replies: 5
    Last Post: 04-25-2013, 10:36 AM
  5. Replies: 1
    Last Post: 09-14-2012, 10:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums