Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

MS Outlook COM, how to COM to "send/receive all folders"



  • Please log in to reply
7 replies to this topic
zeus19
  • Members
  • 49 posts
  • Last active: Feb 24 2017 12:59 PM
  • Joined: 14 Apr 2011
I tried to search around forum and in MSDN also but I can not find any code about "send/receive all folders" or maybe my knowledge's not good enough to understand them all. Can someone help me about this with COM_L, thanks alot. And one more question, I can not login chat section, and it tells me that my account has been banned (What did I do?)?

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Have a look here.

zeus19
  • Members
  • 49 posts
  • Last active: Feb 24 2017 12:59 PM
  • Joined: 14 Apr 2011
Thanks for you reply, i can do it now. Many many thanks.

zeus19
  • Members
  • 49 posts
  • Last active: Feb 24 2017 12:59 PM
  • Joined: 14 Apr 2011
Hey Hotkeyit, Cam you help me with this code? Because I want to know when the SendAndReceive finish to execute those code below it, is there anyway to know that???

I also found the SyncObjects in MSDN, and the SyncEnd but I don't know how it works, can you me with this???

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Calling the SendAndReceive method is synchronous.

As far as I understand this means that your application will be suspended until the SendAndReceive finished.

zeus19
  • Members
  • 49 posts
  • Last active: Feb 24 2017 12:59 PM
  • Joined: 14 Apr 2011
ol := ComObjCreate("Outlook.Application")
Session := ol.session
Folders := Session.Folders("Minh").Folders
Loop
{
Session.SendAndReceive(false)
Inbox := Folders.Item("Inbox").Items
ChkNewMail := Inbox.Count
if(ChkNewMail >= 1)
{
  AttCount := Inbox.item(1).attachments.Count
  if(AttCount = 0) ;If no attach files
  {
   ReplyAll := Inbox.item(1).ReplyAll
   ReplyText = Please re-send the e-mail include the "Consignment.ini" file ;Reply All body text.
   ReplyAll.body := ReplyText
   ReplyAll.Send
   Inbox.item(1).Delete
   continue
  } ;Done - no attach files in the email => reply to remind to customers add Consignment.ini file to the email
  else if(AttCount >= 1)
  {
   gosub, FileRedirect
  }
}
}

In my situation, as the code above, when I stopped it to check on Outlook and I got about thousands process in Send/Receive box. That's the reason why I need to know how to get the end event to continue the code without creating a lot of process. Can you help me with it?

zeus19
  • Members
  • 49 posts
  • Last active: Feb 24 2017 12:59 PM
  • Joined: 14 Apr 2011
Dim myOlApp As New Outlook.Application
Dim WithEvents mySync As Outlook.SyncObject
Sub Initialize_handler()
Set mySync = myOlApp.Session.SyncObjects.Item(1)
mySync.Start
End Sub
  
Private Sub mySync_SyncEnd()
MsgBox "Synchronization is complete."
End Sub

I got this code on MSDN web site, and don't know how to translate the "Private Sub" statement to Autohotkey COM, can you help?

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
✓  Best Answer
Try this:
#Persistent
outlook:=ComObjActive("Outlook.Application")
sync:=outlook.Session.SyncObjects.Item(1)
ComObjConnect(sync,"MySync_")
sync.Start
return
Esc::ExitApp
MySync_SyncEnd(){
MsgBox Synchronization is complete.
}