Send All emails in Outbox and Quit using VBA

Status
Not open for further replies.
S

Steph_canoe

Hi,

I have MS Access creating emails objects in Outlook using a macro. I want to

send them all and close outlook after.

1-Open Outlook

2-Send all emails in the outbox folder

3-Close Outlook

How can I achieve it using VBA? Using command buttons does not seem to work

since my Outlook is in French,

I'm using Outlook 2003 SP3.

Thank You

Stephane
 
You're not trying to use command button captions, are you? Use the IDs

instead, with the FindControl method. They're language-neutral. The ID for

Send All should be 5577.

Sue Mosher

"Steph_canoe" wrote:


> Hi,

> I have MS Access creating emails objects in Outlook using a macro. I want to
> send them all and close outlook after.

> 1-Open Outlook
> 2-Send all emails in the outbox folder
> 3-Close Outlook

> How can I achieve it using VBA? Using command buttons does not seem to work
> since my Outlook is in French,

> I'm using Outlook 2003 SP3.

> Thank You

> Stephane
 
"Sue Mosher [MVP]" wrote:


> You're not trying to use command button captions, are you? Use the IDs
> instead, with the FindControl method. They're language-neutral. The ID for
> Send All should be 5577.
> > Sue Mosher
> > >

> "Steph_canoe" wrote:
>
> > Hi,
> > I have MS Access creating emails objects in Outlook using a macro. I want to
> > send them all and close outlook after.
> > 1-Open Outlook
> > 2-Send all emails in the outbox folder
> > 3-Close Outlook
> > How can I achieve it using VBA? Using command buttons does not seem to work
> > since my Outlook is in French,
> > I'm using Outlook 2003 SP3.
> > Thank You
> > Stephane


How would I write my code than:

Public Sub SendReceiveNowDev()

' Instantiate an Outlook Application object.

Set objOutlook = CreateObject("Outlook.Application")

'Set Btn =

Application.ActiveExplorer.CommandBars.FindControl(msoControlButton, 5577)

Btn.Execute

'Stop Outlook

objOutlook.Quit

End Sub

Seems not to work.
 
Here is my updated code but is not working yet:

Public Sub SendReceiveNowDev()

Dim objOutlook As Outlook.Application

Dim objCB As Office.CommandBar

On Error Resume Next

' Instantiate an Outlook Application object.

Set objOutlook = CreateObject("Outlook.Application")

'Then use the Send/Receive on All Accounts

Set objCB =

Application.ActiveExplorer.CommandBar.FindControl(msoControlButton, 5577)

objCB.Execute

Set objCB = Nothing

Set objOutlook = Nothing

'Stop Outlook

objOutlook.Quit

End Sub

"Steph_canoe" wrote:



> "Sue Mosher [MVP]" wrote:
>
> > You're not trying to use command button captions, are you? Use the IDs
> > instead, with the FindControl method. They're language-neutral. The ID for
> > Send All should be 5577.
> > > > Sue Mosher
> > > > > > > > "Steph_canoe" wrote:
> >
> > > Hi,
> > > > I have MS Access creating emails objects in Outlook using a macro. I want to
> > > send them all and close outlook after.
> > > > 1-Open Outlook
> > > 2-Send all emails in the outbox folder
> > > 3-Close Outlook
> > > > How can I achieve it using VBA? Using command buttons does not seem to work
> > > since my Outlook is in French,
> > > > I'm using Outlook 2003 SP3.
> > > > Thank You
> > > > Stephane


> How would I write my code than:

> Public Sub SendReceiveNowDev()

> ' Instantiate an Outlook Application object.
> Set objOutlook = CreateObject("Outlook.Application")

> 'Set Btn =
> Application.ActiveExplorer.CommandBars.FindControl(msoControlButton, 5577)
> Btn.Execute

> 'Stop Outlook
> objOutlook.Quit

> End Sub

> Seems not to work.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M some emails send from outbox, some don't Using Outlook 10
B Cannot send emails-stuck in OutBox: OUTLOOK 2013 Using Outlook 4
D Emails stuck in Outbox, not receiving emails, Outlook 2010 auto send/receive Using Outlook 4
M I cant send emails via Outlook in my W10 PC. Using Outlook 3
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
E How to send automatic emails in outlook 2010 Using Outlook 1
A Block user to send emails to specific set of email ids Using Outlook 1
N VBA Script to Send Automatic Emails from Outlook 2010 Outlook VBA and Custom Forms 1
M configure Onpremise exchange to send/receive emails internally and externally) Exchange Server Administration 0
V Copy and paste body and subject and send multiple emails Outlook VBA and Custom Forms 3
K Outlook send emails without attachment to a list Using Outlook 1
wisedave Office 365 Outlook - Emails send but don't receive Using Outlook 12
G Script in rule to send to multiple emails found in message bo Outlook VBA and Custom Forms 11
H Can't Send to specific emails Using Outlook 1
M Outlook wont send emails but receives Using Outlook 1
T How to send to spam/delete emails with specific heading? Using Outlook 3
J Send Multiple Emails Using Outlook 1
R Emails won't come into outlook but can send Using Outlook 0
L Cannot send emails through @live.co.uk account in outlook 2013 Using Outlook 0
L Cannot send emails through @live.co.uk account in outlook 2013 Using Outlook 2
D Outlook 2013 deletes emails, does not send them to Deleted Items or Trash Using Outlook 2
M button to send and print emails Using Outlook 26
I How to send just a few emails at a time to a large group in Outlook 2010 Using Outlook 3
I Outlook 2003 won't send emails through one router, but will through another Using Outlook 1
A Outlook won't send emails Using Outlook 1
A Setting Emails to be send in calendar holidays to group of people Using Outlook 6
G Not able to send ANY emails due to a blocked list Using Outlook 2
R Outlook 2010 Not Recieiving Emails Automatically, Have tohit Send / Recieve Using Outlook 1
N Unable to send emails Exchange Server Administration 0
S Outlook 2007 will not send emails Using Outlook 0
N cannot send emails-SMTP Ports not working for Hotmail Pop3 Using Outlook 3
S Why Cant i send lots of emails from my hotmail in bulk? Using Outlook 1
I Outlook will not fetch or send emails after changes to Win .Net Framework prog Using Outlook.com accounts in Outlook 2
C Not able to send emails with Outlook 2007 using Vista BCM (Business Contact Manager) 1
C Synchronization and taking forever to send Using Outlook 2
D Send on behalf of does not store the base mailbox Using Outlook 0
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
TomHuckstep Remove Send/Receive All Folders (IMAP/POP) button from Outlook 365 Ribbon Using Outlook 2
J Macro to send email as alias Outlook VBA and Custom Forms 0
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
T Outlook 2010 recipient no longer shows in 'Send To' Using Outlook 0
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
Geldner Tweak Junk Email Reporting tool to default to particular email on send? Using Outlook 3
Geldner Send / Receive a particular group via macro or single keypress Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
L How to avoid issues with "Send on Behalf" Using Outlook 3
M Outlook 365 refuses to send email Using Outlook 0

Similar threads

Back
Top