vieirasoft 3/2/2011, 20:03
Experimente do Mestre Jpaulo para um colega em outro fórum
Public Function Outlook_Contacts_2_Access()
On Error GoTo No_Bugs
Dim CnnA As ADODB.Connection
Dim goRs As ADODB.Recordset
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oInbox As Outlook.MAPIFolder
Dim oEmail As Outlook.MailItem
Dim i As Integer
Set oApp = New Outlook.Application
Set oNS = oApp.GetNamespace("MAPI")
Set oInbox = oNS.GetDefaultFolder(olFolderInbox)
Dim sSQL As String
Set CnnA = New ADODB.Connection
Set goRs = New ADODB.Recordset
'YOU WILL NEED TO CREATE YOUR TABLE IN ACCESS TO MATCH AND CALL IT INBOX
sSQL = "SELECT * FROM [Inbox] WHERE 1=2;"
goRs.Open sSQL, CnnA, adOpenKeyset, adLockOptimistic, adCmdText
frmMain.prbProgress.Max = oInbox.Items.Count
i = 1
Do While i <= oInbox.Items.Count
Set oEmail = oInbox.Items(i)
DoEvents
goRs.AddNew
goRs!To = oEmail.To
goRs!CC = oEmail.CC
goRs!BCC = oEmail.BCC
goRs!Subject = oEmail.Subject
goRs!Body = oEmail.Body
goRs!HTMLBody = oEmail.HTMLBody
goRs!Importance = oEmail.Importance
goRs!Received = oEmail.ReceivedTime
goRs!MessageClass = oEmail.MessageClass 'EMAIL, MEETING RESPONSE, MEETING REQUEST, ETC.
goRs!ReceivedByName = oEmail.ReceivedByName
'CONTINUE ON WITH OTHER FIELDS YOU WANT
'...
goRs.Update
Set oEmail = Nothing
frmMain.prbProgress.Value = i
i = i + 1
Loop
Set oEmail = Nothing
Set oInbox = Nothing
Set oNS = Nothing
goRs.Close
Set CnnA = Nothing
Set goRs = Nothing
Exit Function
No_Bugs:
MsgBox Err.Number & "-" & Err.Description, vbCritical, "Outlook Email Export"
Resume Next
End Function
Em alternativa experimente também esse
Option Compare Database
Option Explicit
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oWindow As Object
Dim omail As Outlook.MailItem
Private Sub Comando12_Click()
Set oApp = New Outlook.Application
Set oNS = oApp.GetNamespace("MAPI")
Set oWindow = oApp.ActiveWindow
Set omail = oApp.ActiveExplorer.Selection.Item(1)
txt_remetente = omail.SenderName 'Remetente
txt_cc = omail.CC 'Com cópia
txt_assunto = omail.Subject 'Assunto
txt_mensagem = omail.Body 'Mensagem
txt_para = omail.To 'Destinatário
txt_data = omail.ReceivedTime
End Sub