Link to home
Start Free TrialLog in
Avatar of nesto2008
nesto2008

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nesto2008
nesto2008

ASKER

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

User generated image
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.