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
Thema durchsuchen
Ansicht
Themen-Optionen

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
Antwort Antwort
Delphi-Lover

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

Outlook, how to add an address in a distribution list

  Alt 19. Okt 2004, 09:35
Hello,

I've tried to add a new mailaddress in an addresslist, but I got an error when doing so. I can not find an other way to add an address.

Thanks a lot,

Delphi-Lover.

Delphi-Quellcode:
Var obj, Entry, NewMember : OleVariant;
begin
  obj := CreateOleObject('outlook.application');
  obj := obj.GetNameSpace('MAPI');

  //Create an new distribution list
  //AddressList(6) is my personal addressbook
  Entry:=obj.AddressLists(6).AddressEntries.Add('MAPIPDL','New List');
  Entry.Update;

  NewMember:=Entry.members;
  //Error Here:
  NewMember.Add('SMTP','NewName');
End;
[edit=sakura] inserted the [delphi] tags Mfg, sakura[/edit]
Rob
  Mit Zitat antworten Zitat
Benutzerbild von fkerber
fkerber
(CodeLib-Manager)

Registriert seit: 9. Jul 2003
Ort: Ensdorf
6.723 Beiträge
 
Delphi XE Professional
 
#2

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

  Alt 19. Okt 2004, 11:15
HI!

Welcome in DP

Can you tell us what error it is?

Ciao Frederic
Frederic Kerber
  Mit Zitat antworten Zitat
Delphi-Lover

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

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

  Alt 19. Okt 2004, 12:20
Hi,

The error message I've to translate to English:

EOLEException:
There is an attempt beiing made to open a non existing property.

Greets,

DL.
Rob
  Mit Zitat antworten Zitat
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
Delphi-Lover

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

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

  Alt 28. Okt 2004, 15:58
Hello,

If you want to add more members to the Distribution List then use the "myDistList.Save;" AFTER you add ALL the members!

Greets,

Delphi Lover.
Rob
  Mit Zitat antworten Zitat
Benutzerbild von Nikolas
Nikolas

Registriert seit: 28. Jul 2003
1.528 Beiträge
 
Delphi 2005 Personal
 
#6

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

  Alt 28. Okt 2004, 16:00
[OT] Warum unterhaltet ich euch nicht einfach auf deutsch? [/OT]
Erwarte das Beste und bereite dich auf das Schlimmste vor.
  Mit Zitat antworten Zitat
Benutzerbild von fkerber
fkerber
(CodeLib-Manager)

Registriert seit: 9. Jul 2003
Ort: Ensdorf
6.723 Beiträge
 
Delphi XE Professional
 
#7

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

  Alt 28. Okt 2004, 19:49
Hi!

Zitat von Toxman:
[OT] Warum unterhaltet ich euch nicht einfach auf deutsch? [/OT]
Vielleich weil der Fragensteller kein Deutsch kann?


Ciao Frederic
Frederic Kerber
  Mit Zitat antworten Zitat
Delphi-Lover

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

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

  Alt 1. Nov 2004, 09:55
Hello,

Yes, indeed my German is not that good. If you read the source above you can even discover where I'm coming from... Beside this, I see the power of these kind of Forums (where you don't have to pay!) and I think a lot of (Delphi) people all over the world will find on delphipraxis.net the answer on their questions (be Google Bei Google suchen Delphi Lover Outlook friendly!) Especially if the database will grow and grow the coming years. I think they will be very happy if the language is in English. Also all my sources I write are in English. I forced myself to do so, because the IT world is very international and for other programmers it is very difficult to read if sources (variables/comments) are in not English language. Also if you are a professional developer then a lot of other programmers have to work with your sources and companies nowadays take employees from all over the world.

Greets and keep this GREAT Formum alive!

Delphi Lover.
Rob
  Mit Zitat antworten Zitat
Antwort Antwort


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 04:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz