Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Microsft Outlook Objects

    I am writing some VBA code to send an email using MS Access 2010 through MS Outlook 2010.

    In the tutorial that I have seen it says you must activate Microsoft Outlook Objects (Tools then References).

    I have done that on MS Access 2010, but it is version 14.0. I need to know is that adequate correct for this
    version of MS Access 2010.

    Also when does this have to be done? I have already written the code to send the email and thus would have to load
    Microsoft Outlook Objects after the fact (the code is already written).

    Any help appreciated. Thanks in advance.


    Respectfully,


    Lou Reed

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Add the reference to it, in a code window on any form, go to Tools, References and scroll down the list to find the Microsoft Outlook Objects reference and select it. Save then still in the code window do a Compile to see if you have any issues. Test your email and see if it works. I would make a backup copy of the database before doing these changes incase you need an easy way back if things mess up.

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Thanks I will give it a try.

    Respectfully,

    Lou Reed

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I have nit got the email ready to test so I am wondering if there is another way that I can test to see if Microsoft Outlook Objects is loaded.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    In the References list, if it is checked with no "Missing:" text then it is good. But you need to do a test to verify it will work as you want. Just do an email to yourself with hardcoded values to test.

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    What are the consequences if this does not correctly load?

    I mean exactly what would I see on the screen if it incorrectly loads or fails to load?

    Thanks in advance.

    Respectfully,


    Lou Reed

  7. #7
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    In the code window, do Debug and Compile and see if it gives an error or not. If no errors then you might be good to go.

  8. #8
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Well, I am ahead of you there. That is exactly what I have done. It gags on certain lines such as

    Me.Attachments = file

    or

    Me.txtBody

    Me.txtSubject

    Me.txtTo

    me.Attachments = Null


    I am not sure, why they fail, that is just a sampling. I am trying to

    upload a *.png screen of all the lines that compile fails on and that

    has not been easy or direct uploading a *.zip file.

    I have a separate post on it.


    Any help appreciated.


    Respectfully,

    Lou Reed

  9. #9
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Me.Attachments = file
    Is file the variable that has the patth to the file you want to attach? May need to put the actual path there.


    Are the fields on your form called txtBody, txtSubject, etc.? Are you calling this code from the form that has those fields? If not the Me. won't work, you will need the full path of the form they are on like Forms!frmMain!frmEmail!txtBody

    Me.txtBody

    Me.txtSubject

    Me.txtTo

    me.Attachments = Null

  10. #10
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    uploaded a screenshoy of the errors on compile

    I have uploaded a zipped file (correctly this time) of the errors that occur when I try to compile the
    VBA code.

    I am almost certain it is some systemic issue because off the similarity of the errors.

    This is simply a screenshot of the code after I click the dropdown menu and then clicked compile.

    I will check the options that you enumerated in the previous post.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  11. #11
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Not sure where to help you with this, maybe others can help direct you with your code. Can you take a screenshot of your References box and paste it in here? So you cannot even get your code to run it bombs out on the compile?

    What about just using a simple SendObject line but with an attachment?

    DoCmd.SendObject acSendTable, "Employees", acFormatXLS, _
    "Nancy Davolio; Andrew Fuller", "Joan Weber", , _
    "Current Spreadsheet of Employees", , False

    https://msdn.microsoft.com/en-us/lib...ffice.12).aspx

    Or maybe check out some email examples in the Code library:

    https://www.accessforums.net/showthread.php?t=41579



  12. #12
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    On post number 9, you have the line

    me.Attachments = Null


    There is an extra s on me.Attachments. I assume there was a reason for this.

    I tried the code as you suggested. No luck.

    So now me.Attachments = Null and me.Attachment = Null

    neither work. I am not sure why

    me.Attachment works in a earlier subprogram without the s.

    What was the reason for the original line that you typed?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  13. #13
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You may have hit one of those times where Access does not like Me.txtControlName. Because you have the period in the reference, it thinks you are referring to a form property which doesn't exist, so you get an error. Try changing all your form control references to Me!txtControlName (using the !) to see if that helps.

  14. #14
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    You may have hit one of those times where Access does not like Me.txtControlName. Because you have the period in the reference, it thinks you are referring to a form property which doesn't exist, so you get an error.  Try changing all your form control references to Me!txtControlName (using the !) to see if that helps.

    Please explain in more detail this statement. It went right over my head.

    Thanks in advance.

    Respectfully,

    Lou Reed

  15. #15
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Quote Originally Posted by Lou_Reed View Post
    On post number 9, you have the line

    me.Attachments = Null
    That is what you posted above, that is not my lines. Look at your post #8. Honestly I think you should ditch your code and use the one from the link I provided as that one should work. Also take a snapshot of your Reference list of dlls and post it here. Did you ever check the reference for the Microsoft Outlook Objects (Tools then References)?

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Network Access Issue with Microsft Access 2013
    By dferreira in forum Access
    Replies: 6
    Last Post: 07-21-2016, 11:41 AM
  2. Microsft Access Query Help
    By rplum in forum Queries
    Replies: 2
    Last Post: 06-29-2016, 09:48 AM
  3. Replies: 0
    Last Post: 12-15-2014, 08:18 AM
  4. Replies: 11
    Last Post: 05-20-2014, 11:32 AM
  5. Assigning Outlook task from shared Outlook mailbox
    By Remster in forum Programming
    Replies: 2
    Last Post: 11-16-2011, 04:38 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