Send Receive script

Hi there,

I require a send/receive script in MS outlook 2010 to execute as soon as a email is received,  so if i receive an email I need it to send receive again after 3 seconds.

Is this possible?

Thanks in advance

Ernie
nesto2008Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
try:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Application_NewMail()
    Sleep 3000
    ThisOutlookSession.SendReceiveGroup
End Sub

Open in new window


you can increase the delay when necessary

>>Sleep 3000
it means delay for 3 seconds
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nesto2008Author Commented:
Perfect, sorry to ask but how do i get it into outlook 2010 now ?, where do i put this?
This will sent out emails if i receive them within 10 seconds of each other?, so 10 emails in 6 seconds apart, this script will send them out 3 seconds after i receive each one?

Thanks

Ernie
0
Ryan ChongCommented:
>>sorry to ask but how do i get it into outlook 2010 now ?, where do i put this?
you can go to menu Tools > Macro > Macro or press Alt + F11 to access the VBA scripts, you can paste the scripts above there

>>This will sent out emails if i receive them within 10 seconds of each other?
it depends on how fast your outlook/working machine and probably internet bandwidth in that environment. But the scripts provided above is to trigger the "Send/Receive" button via VBA.

>>so 10 emails in 6 seconds apart, this script will send them out 3 seconds after i receive each one?
To be frank, I'm not testing in this part in which if 2 emails were received within a short interval (let's say few seconds' gap), will outlook triggers it once or twice. But I believe it will be once email received, it will trigger Application_NewMail() event once.
1
ebstkpicsCommented:
I am not able to insert this into outlook, it wont let me run it as a script in rules, can you please explain to me how to insert this so it is running in the current outlook session ans how to apply it in rules to run whenever i receive a email?

Thanks

Ernie
0
Ryan ChongCommented:
>>can you please explain to me how to insert this so it is running in the current outlook session ans how to apply it in rules to run whenever i receive a email?

first, as mentioned, to insert the scripts into your current outlook session, try:
>>you can go to menu Tools > Macro > Macro or press Alt + F11 to access the VBA scripts, you can paste the scripts above there

second, I just found out a way to integrate our own-written scripts into the Rules...

Pls look for the "Run a Script" option from the Rule Wizard.

Rules: Run a script
For more info, pls read this article:

Outlook's Rules and Alerts: Run a Script
http://www.slipstick.com/outlook/rules/outlooks-rules-and-alerts-run-a-script/

So your scripts need to be changed to something similar to this:
Public Sub SendReceiveGroup(Item As Outlook.MailItem)
    
    Dim colSyc As Outlook.SyncObjects
    Dim syc As Outlook.SyncObject
     
    Set colSyc = Application.GetNamespace("MAPI").SyncObjects
 
    For i = 1 To colSyc.Count
        Set objSyc = colSyc.Item(i)
        Debug.Print objSyc.Name
        objSyc.Start
    Next
End Sub

Open in new window

then apply the steps as mentioned in article above.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.