Toon posts:

[Delphi] Import Outlook custom fields

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb een stukje code dat de NAW etc. velden van het object Contact uitleest
van een Outlook.Application. De tekst wordt in een stringgrid geplakt. So far, so good. Echter, in Outlook 2000 wordt een formulier gebruikt met daarop z.g. custom fields. De import die alle properties van object Contact ophaalt, slaat deze fields over.

Delphi:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
procedure TForm1.Button1Click(Sender: TObject);
const
  olFolderContacts = $0000000A;
var
  outlook, NameSpace, Contacts, Contact: OleVariant;
  i,j: Integer;
begin
  outlook := CreateOleObject('Outlook.Application');
  NameSpace := outlook.GetNameSpace('MAPI');

  Contacts := NameSpace.GetDefaultFolder(olFolderContacts);
  StringGrid1.RowCount := Contacts.Items.Count;
  Edit1.Text := IntToStr(Contacts.Items.Count);
  ProgressBar1.Max := Contacts.Items.Count;
  Button1.Enabled := false;
  for i := 1 to Contacts.Items.Count do
  begin

    Contact := Contacts.Items.Item(i);
    StringGrid1.Cells[1,i] := Contact.FullName;
    StringGrid1.Cells[2,i] := Contact.BusinessAddress;
    Application.ProcessMessages;
    ProgressBar1.Position := i;
  end;
  Button1.Enabled := true;
  Outlook := UnAssigned;

  end;


Ik zoek dus een veld dat Contact.Mail_Recipient heet, maar nergens te vinden. Heb de hele GoT databak nagekeken, maar niet te vinden.

Verwijderd

Kan je die custom fields wel bij naam opvragen? (ik ben hier tijd terug ook 's mee bezig geweest, dacht dat dat anders ging.)

Heb de code niet bij de hand, hoe ik dat eerst deed, is op zich vrij simpel.


echter, onontbeerlijk is het volgende proggie:
http://www.dimastr.com/outspy/ (kan je alles netjes inkijken van outlook com objecten)

[ Voor 19% gewijzigd door Verwijderd op 17-09-2003 14:10 ]


Verwijderd

Topicstarter
Nee, kan ze niet opvragen, krijg ik een keiharde 'Method not supported'. Ga even naar je tooltje kijken. Vast dank.

Verwijderd

Topicstarter
Kun je nog eens kijken naar die code? Dat OutlookSpy geeft veel info, maar die customfields kan ik niet vinden.

Verwijderd

Ik denk dat je het moet zoeken in:
cMailRecipient := Contact.Fields.Item('mail_recipient');


ik ook niet direct met die spy, heb wel dit gevonden:
Bron: www.cdolive.com
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'   Get the contacts folder of the mailbox
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts)
' Get the first message of the contacts folder
' Note that it is still a message object
' So the class property will always return a value of CdoMsg
Set objMessages = objFolder.Messages
Set objMessage = objMessages.GetFirst()

' Get the fields collection of the contact item
Set objFields = objMessage.Fields

' Get a single field using the MAPI property tag
Set objField = objFields.Item(<PropertyTag>)

' For Example:
Set objField = objFields.Item(&H3001001E)

' If it is a Microsoft Outlook item you can either use
Set objField = objFields.Item("<PropertyTag>", "<PropertySetID>")

' For Example:
Set objField = objFields.Item("0x8535", "0820060000000000C000000000000046")

' Or the following syntax if you want to read the value directly
Value = objFields.Item("{" & "<PropertySetID>" & "}" & "<PropertyTag>").Value 

' For Example:
Value = objFields.Item("{0820060000000000C000000000000046}0x8535").Value

' If it is a Microsoft Outlook item with a custom field use the following syntax:
Set objField = objFields.Item("<NameOfUserdefinedField>")

' For Example:
Set objField = objFields.Item("PersonRole")

[ Voor 14% gewijzigd door Verwijderd op 17-09-2003 14:37 ]