PST में MapiDistributionList जोड़ना

नया PST बनाएं, सबफ़ोल्डर और संदेश जोड़ें दिखाया गया है कि कैसे PST फ़ाइल बनाएं और उसमें एक सबफ़ोल्डर जोड़ें। Aspose.Email के साथ आप एक MapiDistributionList आपके द्वारा बनाई या लोड किए गए PST फ़ाइल के Contacts उपफ़ोल्डर में।

फ़ाइल से MapidistributionList लोड करें

नीचे दिया गया कोड फ़ाइल से MAPI वितरण सूची को लोड करता है।

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
String dataDir = "data/";

MapiMessage msg = MapiMessage.load(dataDir + "DistList.msg");
MapiDistributionList dlist = (MapiDistributionList) msg.toMapiMessageItem();

System.out.println("Members: " + dlist.getMembers().size());

एक नया MapiDistributionList बनाएँ और उसे Contacts उपफ़ोल्डर में जोड़ें

एक जोड़ने के चरण नीचे दिए गए हैं MapiDistributionList PST में:

  1. नया PST बनाएँ।
  2. Contacts फ़ोल्डर को PST में जोड़ें।
  3. नमूना कांटैक्ट्स बनाएँ।
  4. बनाए गए कांटैक्ट्स के आधार पर एक वितरण सूची बनाएँ।
  5. वितरण सूची को PST में जोड़ें।

निम्नलिखित कोड स्निपेट दिखाता है कि कैसे एक MapiDistributionList और फिर इसे नए बनाए गए PST फ़ाइल के Contacts फ़ोल्डर में जोड़ें।

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
String dataDir = "data/";

String displayName1 = "Sebastian Wright";
String email1 = "SebastianWright@dayrep.com";

String displayName2 = "Wichert Kroos";
String email2 = "WichertKroos@teleworm.us";

PersonalStorage pst = PersonalStorage.create(dataDir + "pstFileName1_out.pst", FileFormatVersion.Unicode);

// Add the contact folder to the PST
FolderInfo contactFolder = pst.createPredefinedFolder("Contacts", StandardIpmFolder.Contacts);

// Create the contacts; addMapiMessageItem returns the Base64-encoded entry ID
String strEntryId1 = contactFolder.addMapiMessageItem(new MapiContact(displayName1, email1));
String strEntryId2 = contactFolder.addMapiMessageItem(new MapiContact(displayName2, email2));

// Create a distribution list on the basis of the created contacts
MapiDistributionListMember member1 = new MapiDistributionListMember(displayName1, email1);
member1.setEntryIdType(MapiDistributionListEntryIdType.Contact);
member1.setEntryId(java.util.Base64.getDecoder().decode(strEntryId1));

MapiDistributionListMember member2 = new MapiDistributionListMember(displayName2, email2);
member2.setEntryIdType(MapiDistributionListEntryIdType.Contact);
member2.setEntryId(java.util.Base64.getDecoder().decode(strEntryId2));

MapiDistributionListMemberCollection members = new MapiDistributionListMemberCollection();
members.addItem(member1);
members.addItem(member2);

MapiDistributionList distributionList = new MapiDistributionList("Contact list", members);
distributionList.setBody("Distribution List Body!");
distributionList.setSubject("Distribution List Subject!");

// Add the distribution list to the PST
contactFolder.addMapiMessageItem(distributionList);

एक बार की वितरण सूची बनाएँ

इस वितरण सूची के लिए अलग-अलग कांटैक्ट्स की आवश्यकता नहीं है।

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
String dataDir = "data/";

PersonalStorage pst = PersonalStorage.create(dataDir + "pstFileName2_out.pst", FileFormatVersion.Unicode);

// Add the contact folder to the PST
FolderInfo contactFolder = pst.createPredefinedFolder("Contacts", StandardIpmFolder.Contacts);

MapiDistributionListMemberCollection oneOffMembers = new MapiDistributionListMemberCollection();
oneOffMembers.addItem(new MapiDistributionListMember("John R. Patrick", "JohnRPatrick@armyspy.com"));
oneOffMembers.addItem(new MapiDistributionListMember("Tilly Bates", "TillyBates@armyspy.com"));

MapiDistributionList oneOffMembersList = new MapiDistributionList("Simple list", oneOffMembers);
contactFolder.addMapiMessageItem(oneOffMembersList);