SELF Solved: outlook sync from excel

cdkeito

Board Regular
Joined
Aug 26, 2005
Messages
95
hi all,

a litle question:

how do you make outlook to start posting yours email after the well know .send or .display (sendkeys "%s")?
I presume something like this:

Code:
Dim colSyncObjects As Outlook.SyncObjects
Dim objSyncObject As Outlook.SyncObject

Sub StartSync()
   Set colSyncObjects = Session.SyncObjects
   Set objSyncObject = colSyncObjects("All Folders")
   objSyncObject.Start
End Sub

I start with outlook closed (only excel).
(If i's not clear, I'm interested in the START metod)
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

cdkeito

Board Regular
Joined
Aug 26, 2005
Messages
95
I think that is outlook only code, so i need only a port to excel code.

like (I think):
Code:
Sub sync_sync()
Dim OLSyncs As Outlook.SyncObjects
Dim OLSync As Outlook.SyncObject 
Set OLApp = CreateObject("Outlook.Application")
Set OLMAPI = OLApp.Getnamespace("mapi")
Set OLSyncs = OLMAPI.SyncObjects
Set OLSync=OLSyncs.Item("All Accounts")
OLSync.start
Set OLSync = nothing 
Set OLSyncs = nothing
Set OLMAPI = nothing
Set OLApp = nothing
End Sub
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web

ADVERTISEMENT

Hi there,

Are you looking to Sync your items or automatically send an email from Excel without having to click the Send button?
 

cdkeito

Board Regular
Joined
Aug 26, 2005
Messages
95
I'm looking in the outlook's "start" metod to begin to send those email builded with excel (see 1st post), overwise they stay in the closed outlook (even if you make a send).

so: I'm looking to Sync my items.

Now, after running my macro, i'll have to open outlook and start manualy (or wait for the auto one) the send/receive porcess.

I can use a keysend on outlook, but it has its on functions.
 

cdkeito

Board Regular
Joined
Aug 26, 2005
Messages
95

ADVERTISEMENT

sorry for my bad english.
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
If you are running routine(s) from within Excel that create Outlook mail messages and you want to directly send them, post the code you are using and the steps taken with it thus far.
 

cdkeito

Board Regular
Joined
Aug 26, 2005
Messages
95
Its very very long, but i can post the fuction to manage mail:
Code:
Function Mail_Outlook(ind As String)
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strdate As String
    strdate = "Elaborati"
    DefPath = ThisWorkbook.path
    If Right(DefPath, 1) <> "\" Then
        DefPath = DefPath & "\"
    End If
    FileNameZip = DefPath & strdate & ".zip"
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(olMailItem)
        With OutMail
            .To = "" & ind & ""
            .CC = ""
            .BCC = ""
            .Subject = "CLIENTI ATTIVI"
            .Body = "regalo"
            .Attachments.Add FileNameZip
            .Display
            Application.Wait (Now + TimeValue("0:00:02"))
            Application.SendKeys "%a"  ' send
            Application.Wait (Now + TimeValue("0:00:02"))
        End With
        Kill FileNameZip
    Set OutMail = Nothing
    Set OutApp = Nothing
End Function
In the main routine I want to add a :
"and you want to directly send them"
so I's looking for the start metod above.

At very last resort I can use something like:
Code:
Dim OutApp As Outlook.Application
Set OutApp = CreateObject("Outlook.Application")
OutApp.visible = True
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%r" ' send & receive
Application.Wait (Now + TimeValue("0:00:02"))
Set OutApp = Nothing
when I can, I'll some of those codes.
 

Watch MrExcel Video

Forum statistics

Threads
1,119,270
Messages
5,577,117
Members
412,769
Latest member
VK12345
Top