Link to home
Start Free TrialLog in
Avatar of yogithite
yogithiteFlag for India

asked on

Script to Get count of new mails in Outlook

Hi,

I need to write a VB Script or VC++ program to get total number of new emails in outlook. Can anyone tell me or point me at suitable code/documentation?

Thanks in Advance,

Y
Avatar of Bill Prew
Bill Prew

Avatar of yogithite

ASKER

Thanks for info bp...

What does SERVERNAME and MAILBOXNAME stand for? is it the IP of server and mail client name?

cscript ProcessNotesEmails.vbs SERVERNAME MAILBOXNAME
+ one more thing,

I want to run this script on the client side. My mail server is hMailServer. Asif now, I am trying to write the script w.r.t. http://www.hmailserver.com/documentation/latest/?page=com_objects

Y
I was able to write/get code for getting unread mails in Inbox.

This attached script is limited only to get unread mails from Inbox - and not from Sub folders.

Can anyone help me to update this script to traverse through sub folders and get count of unread mails?

Any help is appreciated, Thanks in Advance.
' *****************************************************
'     Script To Display Unread Outlook Mail Items     *
'                                                     *
' ***************************************************** 

Dim objOutlook
Dim objNameSpace
Dim objFolder
Dim CurrentItem
Dim Count 
Const olFolderInbox = 6 
    Set objOutlook = CreateObject("Outlook.application")
    Set objNameSpace = objOutlook.GetNameSpace("MAPI")
    Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox) 
    For Each CurrentItem in objFolder.Items
        If CurrentItem.Unread then
            Count = Count+1
        End If
    Next 
Msgbox("Unread Messages in Inbox:" &Count) 
 
' ****  Clean up
'
    Set objFolder = Nothing
    Set objNameSpace = Nothing
    set objOutlook = Nothing

Open in new window

Hi bp, Again, thanks for your input.

Code which you are pointing at is VBA code and I need VBS script. Fact is - I dont know VBA and macros and many other things. I am newbie to all this coding work. I am managing somehow with VB Script in critical time.

I would appreciate if anyone helps me out for completing above script for traversing through sub folders and get count of unread mails?

Regards,
Y
error.jpg
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

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
Thanks alot bp for your kind help!! I really appreciate your help.

Yogi
Hi ,

is there any way to update this same script for getting sync complete notification?
You might take a look at this thread.  Your question is quite a bit different though than what this current question was about, just counting unread emails.  Trapping sync complete events is more complex.

https://www.experts-exchange.com/questions/24897422/Detect-completion-of-Outlook-Send-Recieve.html

~bp