+ Reply to Thread
Results 1 to 12 of 12

Can't initiate Outlook 'Send/Receive All Folders' from Excel

  1. #1
    Registered User
    Join Date
    02-20-2015
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    7

    Can't initiate Outlook 'Send/Receive All Folders' from Excel

    Hi Guys,

    I really need some help here. My situation is that I need to use a computer which has Outlook 2016 with the 'Send immediately when connected' option unticked (so all emails go to the Outbox when they're initially sent) and I can't do anything about that.

    I'm trying to write a really simple macro that performs the following steps:

    1) Construct an email message from within Excel
    2) Transfer the message from Excel to Outlook 2016 and 'send' it from the default email account
    3) Move it from the Outbox to the Sent Items folder (i.e. properly sending it)

    All of my somewhat limited VBA experience has been within the Excel application and I'm not really familiar with automation of other apps. I've borrowed code from other threads (many thanks!) and I've managed to complete steps 1 & 2 with no problems. However, I'm stuck on step 3.

    I've obtained some code for this which I thought would work but it just doesn't seem to do anything at all. When I step through the code line by line, I don't get any error whatsoever but the email that was created and sent at steps 1 and 2 just remains stuck in the Outbox. The same is true whether Outlook is closed or running at the start of the macro.

    Does anybody have any ideas as to where I'm going wrong? I'd really appreciate you taking a look - my code is as follows:

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    I have a similar situation but have attacked it in a different way within Outlook, rather than Excel. I have a timer that runs every couple of minutes and checks for mail sitting in my Outbox. If there is anything there, it prompts me, asking me if I want to send. If I click yes, I use the following code to do this where GroupName is a string giving the name of the Send/Receive group I have defined for this account:
    Please Login or Register  to view this content.
    Because you are running from Excel, use MyApp instead of Application.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-20-2015
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    7

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    Thanks very much for your reply 6StringJazzer but I really need to try and automate this so that it doesn't require user-intervention in Outlook. The computer will be unattended whilst the macro runs and I need the emails to automatically send at the point they're created by Excel.

    I've seen a few snippets of code in various forums that claim to do the trick but I just can't seem to get any of them to work. I don't really understand what GetNamespace("MAPI") is all about and I think I'm probably trying to use it in a way that it's not supposed to be used.

    Any thoughts? Thanks again!

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    You don't have to adopt my whole solution, just try that line of code, changing Application to myApp. I know that this code works.

    You can think of a NameSpace as the highest level in the hierarchy of Outlook data. It is the gateway to get any other objects. I am not an expert at the Outlook object model, but you need to get the NameSpace before you can get folders, etc.

  5. #5
    Registered User
    Join Date
    02-20-2015
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    7

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    Thanks again 6StringJazzer but I get Run-time error 450 (Wrong number of arguments or invalid property assignment) when I use your line of code as follows:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-20-2015
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    7

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    Just by way of an update, I've actually discovered that the code in my original post does in fact work, but only if my 'send-from' email account is designated as being included in a Send/Receive Group in Outlook.

    For some reason, by default, my email account isn't included in any Send/Receive Group, yet I can still send and receive emails with no problem by clicking Send/Receive (or hitting F9). Therefore, I'd assumed that SyncObjects would just emulate me initiating a Send/Receive and hence send and receive the account too, but it clearly doesn't!

    So, I think my issue is less Excel and more Outlook related and, whilst I'd still be extremely interested to hear any ideas from ExcelForum, I've posted a related thread with the good people at Slipstick. I'm a newbie and so I'm not allowed to post any links but, if you want to follow up further, you can search Slipstick for "Email not leaving Outbox when using Excel VBA to sync Outlook account"

    Cheers, Mattypuss

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    I would ask that you enter the link, click on Go Advanced below the edit box,and uncheck "Automatically parse links in text". This will prevent the link from being hot, and I think it will be allowed.

  8. #8
    Registered User
    Join Date
    02-20-2015
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    7

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    I would ask that you enter the link, click on Go Advanced below the edit box,and uncheck "Automatically parse links in text". This will prevent the link from being hot, and I think it will be allowed.
    It still wasn't allowed!

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    Please enter the link as text ( remove the http:// part or whatever necessary)

  10. #10
    Registered User
    Join Date
    02-20-2015
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    7

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    Link to related Slipstick thread:

    http://forums.slipstick.com/threads/...tlook-account/
    Last edited by 6StringJazzer; 02-01-2020 at 11:22 AM. Reason: Moderator activated link

  11. #11
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    I've actually discovered that the code in my original post does in fact work, but only if my 'send-from' email account is designated as being included in a Send/Receive Group in Outlook.
    I can't help with the above problem, but I have a slightly different approach using 'SendAndReceive' from the NameSpace Object.
    The following code was tested in 32 bit Excel 2016 (Office 365).
    Please Login or Register  to view this content.
    The following is complete working code that can be used 'as is' (provided Outlook is Open and Outlook has at least 2 Email Accounts) is included in the attached file:
    Please Login or Register  to view this content.
    Lewis
    Last edited by LJMetzger; 02-23-2020 at 08:42 PM.

  12. #12
    Registered User
    Join Date
    02-20-2015
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    7

    Re: Can't initiate Outlook 'Send/Receive All Folders' from Excel

    I can't help with the above problem
    Lewis, you've actually completely solved my problem!!! I integrated your lines below into my original code as my Step 3 and it now works perfectly:
    Please Login or Register  to view this content.
    So, whilst I still don't understand why my original method doesn't work, I do now have an alternative working solution.

    A thousand thanks to you Lewis... I can now move forward and your assistance is really appreciated.

    Mattypuss

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel Macro - Visual Basic - Send command to serial port - Receive Data.
    By reiiling in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2017, 09:37 AM
  2. macro to loop through all folders and sub folders of outlook and save to excel
    By excelhelpseeker in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 10-27-2016, 03:24 AM
  3. [SOLVED] Initiate Outlook Emails using Excel
    By 4gurus in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2015, 05:20 PM
  4. [SOLVED] Initiate Meeting Request using excel macro in outlook
    By 4gurus in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-03-2015, 04:32 PM
  5. Send CSV events to Outlook non-default calendar folders via excel?
    By humboldtguy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-04-2013, 12:55 AM
  6. Send and receive without display outlook application
    By Calaozao in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2006, 11:16 AM
  7. Replies: 1
    Last Post: 07-13-2005, 05:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1