Re: mail
> Приветствую!
> Как можно посредствам Visual Basic вытащить адреса эл.почты из
> адресной книги, баз данных аутлука и бата?
>
> --
> Пока!
В MSDN имеет место быть такая статья : HOWTO: Retrieve Alternate E-mail
Addresses Using CDO
и код к ней :
Sample Code
' This code sample assumes a valid reference to CDO (1.x) library.
' To use CDO (1.0) library, however, you must declare all CDO objects
' variables as Object. For example, "Dim objSession As Object."
Option Explicit
' This constant is not included in the CDO (1.x) type library,
' so you must declare it explicitly or use the provided
' value directly.
Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E
Private Sub Command1_Click()
Dim objSession As MAPI.Session
Dim objMessage As MAPI.Message
Dim objRecip As MAPI.Recipient
Dim objField As MAPI.Field
Dim v
' Create Session object and Logon.
Set objSession = CreateObject("MAPI.Session")
objSession.Logon
' Show AddressBook and choose a recipient.
Set objMessage = objSession.Outbox.Messages.Add
Set objMessage.Recipients = objSession.AddressBook(OneAddress:=True)
Set objRecip = objMessage.Recipients(1)
' Show the display name and EX type address.
MsgBox "Display Name: " & objRecip.Name
MsgBox "Default Address: " & objRecip.Address
' Get the PR_EMS_AB_PROXY_ADDRESSES property.
Set objField = _
objRecip.AddressEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)
' PR_EMS_AB_PROXY_ADDRESSES is a multivalued property (PT_MV_TSTRING).
' Therefore, you need to extract the individual members.
For Each v In objField.Value
MsgBox "Foreign System Address: " & v
Next
' Clean up and exit.
Set objMessage = Nothing
Set objRecip = Nothing
Set objField = Nothing
objSession.Logoff
Set objSession = Nothing
Unload Me
End Sub
как импортировать библиотеку CDO я не догадался, поэтому заменил
Dim objSession As MAPI.Session
Dim objMessage As MAPI.Message
Dim objRecip As MAPI.Recipient
Dim objField As MAPI.Field
на
Dim objSession As Object
Dim objMessage As Object
Dim objRecip As Object
Dim objField As Object
но у меня еще какая то ошибка вылетала и VB падал.
Но по крайней мере это иллюстрирует как работать с MAPI на VB.
Еще есть статья : HOWTO: Display Outlook Folder Names
Это про папки. К ней есть код :
Option Explicit
Private Sub Main()
Dim olMAPI As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
'// Modify as appropriate.
Const FOLDER_TO_OPEN = "Mailbox - John Doe"
Set olMAPI = GetObject("",
"Outlook.application").GetNamespace("MAPI")
Call PrintFolderNames(olMAPI.Folders(FOLDER_TO_OPEN), "-
>")
Set olMAPI = Nothing
End Sub
Sub PrintFolderNames(tempfolder As Outlook.MAPIFolder, a$)
Dim i As Integer
If tempfolder.Folders.Count Then
Debug.Print a$ & " " & tempfolder.Name
For i = 1 To tempfolder.Folders.Count
Call PrintFolderNames(tempfolder.Folders(i), a$ & "-
>")
Next i
Else
Debug.Print a$ & " " & tempfolder.Name
End If
End Sub
но его я не проверял...
С уважением, Виктор.
-*Информационный канал Subscribe.Ru
Написать в лист: mailto:comp.soft.prog.prog-list@subscribe.ru
Отписаться: http://subscribe.ru/member/unsub?grp=comp.soft.prog.prog&email=
http://subscribe.ru/ mailto:ask@subscribe.ru