AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Outlook, how to add an address in a distribution list

Outlook, how to add an address in a distribution list

Ein Thema von Delphi-Lover · begonnen am 19. Okt 2004 · letzter Beitrag vom 1. Nov 2004
 
Delphi-Lover

Registriert seit: 19. Okt 2004
Ort: Amsterdam
30 Beiträge
 
Delphi 2005 Professional
 
#4

Re: Outlook, how to add an address in a distribution list

  Alt 21. Okt 2004, 10:49
It seems that I have to answer my own question

To add a contact in a DistributionList you can use an AddMember function. The only disadvantage is that the contact added must be in your contactlist already. So the following code creates first the contact and then add the contact to the DistributionList. I don't need the contact after, so at the end I just delete the contact. (It seems the addmember makes a COPY of the contact in the DistributionList)

Greetings,

Delphi-Lover.

Delphi-Quellcode:
uses ComObj;

procedure AddAddressInDistributionList;
Var myOlApp,
    myNameSpace,
    myContact,
    myDistList,
    myMailItem,
    myRecipients : OleVariant;
begin
   myOlApp:=CreateOleObject('outlook.application');
   myNameSpace:=myOlApp.GetNameSpace('MAPI');

   //Create the new Contact
   myContact:=myOlApp.CreateItem(olContactItem);
   myContact.FullName:='New Name';
   myContact.Email1Address:='username@domain.com';
   myContact.Save;
   {
  .FirstName:='Delphi';
  .LastName:='Lover';
  .MobileTelephoneNumber:='123456');
  .HomeAddressStreet:='Delphi Lane 9';
  .HomeAddressCity:='Amsterdam';
  .HomeAddressState:='NL';
  .HomeAddressPostalCode:='1968';
  .Categories:='Business,Personal';
  //More field availble!!
  myContact.Display;
   }


   //Create the Distribution List item
   //olDistributionListItem = 7;
   //this constant is not in my Outlook API...
   myDistList:=myOlApp.CreateItem(7);
   myDistList.DLName:='Test Distribution List';

   //The MailItem is required to
   //create the Recipients collection
   myMailItem:=myOlApp.CreateItem(olMailItem);
   myRecipients:=myMailItem.Recipients;

   //A Contact with the following e-mail address
   //must exist for the AddMembers method to work
   myRecipients.Add('username@domain.com');
   myRecipients.ResolveAll;
   myDistList.AddMembers(myRecipients);
   myDistList.Save;
   //myDistList.Display;

   myContact.Delete;
end;
Rob
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz