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)
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,631
Messages
5,832,768
Members
430,166
Latest member
Nige Leeming

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top