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
 
S

Sue Mosher [MVP]

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
 
S

Steph_canoe

"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.
 
S

Steph_canoe

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
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
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
R How to restrict GWSMO sync to Outlook Send/Receive cycles Using Outlook 0
pwatts2 Restrict some lists to only BCC send option Outlook Wishlist 2
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
glnz O365 - How to send from acct 2 but showing email name from acct 1 as From - alias? Using Outlook 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
C Synchronizing subscribed folders causes hanging during send/receive process Using Outlook 2
M Extract all links from Outlook email, send to Excel Using Outlook 2
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
T After I send a new email, it remains in the Draft folder Using Outlook.com accounts in Outlook 3
B Programmatically force html send and insert clipboard contents into body Outlook VBA and Custom Forms 0
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
M ERROR: None of your email accounts could send to this recipient Using Outlook 2

Similar threads

Top