/// <summary> /// Inserts one or more mail item entries in a single batched request. /// Use this method to reduce HTTP overhead when inserting many emails /// in a single transfer. /// </summary> /// <param name="domain">the domain into which to migrate mail</param> /// <param name="entries">the mail messages to batch insert</param> /// <returns>a <code>MailItemFeed</code> containing the results of the /// batch insertion</returns> public MailItemFeed Batch(string domain, string userName, MailItemEntry[] entries) { Uri batchUri = new Uri(AppsMigrationNameTable.AppsMigrationBaseFeedUri + "/" + domain + "/" + userName + mailFeedUriSuffix + batchFeedUriSuffix); MailItemFeed feed = new MailItemFeed(batchUri, this); foreach (MailItemEntry entry in entries) { feed.Entries.Add(entry); } return base.Batch(feed, batchUri) as MailItemFeed; }
public void Init() { entry = new MailItemEntry(); }
/// <summary> /// Inserts one or more mail item entries in a single batched request. /// Use this method to reduce HTTP overhead when inserting many emails /// in a single transfer. /// </summary> /// <param name="domain">the domain into which to migrate mail</param> /// <param name="entries">the mail messages to batch insert</param> /// <param name="userName">the user for whom this should be done</param> /// <returns>a <code>MailItemFeed</code> containing the results of the /// batch insertion</returns> public MailItemFeed Batch(string domain, string userName, MailItemEntry[] entries) { return Batch(domain, userName, new List<MailItemEntry>(entries)); }
/// <summary> /// Demonstrates inserting several mail items in a batch. /// </summary> /// <param name="numToInsert">the number of entries to insert</param> /// <returns>a <code>MailItemFeed</code> with the results of the insertions</returns> private static MailItemFeed BatchInsertMailItems(int numToInsert) { MailItemEntry[] entries = new MailItemEntry[numToInsert]; // Set up the mail item entries to insert. for (int i = 0; i < numToInsert; i++) { entries[i] = SetupMailItemEntry(i.ToString()); } // Execute the batch request and print the results. MailItemFeed batchResult = mailItemService.Batch(domain, destinationUser, entries); foreach (AtomEntry entry in batchResult.Entries) { GDataBatchEntryData batchData = entry.BatchData; Console.WriteLine("Mail message {0}: {1} {2}", batchData.Id, batchData.Status.Code, batchData.Status.Reason); } return batchResult; }
/// <summary> /// Helper method to set up a new <code>MailItemEntry</code>. /// </summary> /// <param name="batchId">the batch ID for this entry</param> /// <returns>the newly created <code>MailItemEntry</code></returns> private static MailItemEntry SetupMailItemEntry(string batchId) { MailItemEntry entry = new MailItemEntry(); entry.Labels.Add(new LabelElement("Friends")); entry.Labels.Add(new LabelElement("Event Invitations")); entry.MailItemProperties.Add(MailItemPropertyElement.INBOX); entry.MailItemProperties.Add(MailItemPropertyElement.STARRED); entry.MailItemProperties.Add(MailItemPropertyElement.UNREAD); entry.Rfc822Msg = new Rfc822MsgElement(GenerateRandomRfcText()); entry.BatchData = new GDataBatchEntryData(); entry.BatchData.Id = batchId; return entry; }