I need to fetch emails in batches from a mail box which has been through several migrations.
There was an email provider before, then the mail box was migrated to gmail and then to O365.
When I try to use UID, the emails are not fetched in reverse date order.
like this: IMailFolderObject.Fetch(startingUID, EndUID, MessageSummaryItemsObject);
To get emails in reverse date order through Mailkit, I tried to following.
var list = IMailFolderObject.Fetch(0, -1, MessageSummaryItems.Envelope | MessageSummaryItems.UniqueId).ToList();
list.Sort(new OrderBy[] { OrderBy.Date });
The emails are fetched but it takes a real long time to complete the job. Since the mailbox is really large.
I do not want to retrieve all the emails and sort them in my program.
Is there a way to get top 50 emails (sorted by date descending since I can not guarantee the UID order is not matching the order of date descending)
and the rest in batches of 50 in subsequent calls ?
Thanks for help in advance.
This is my first question so please let me know should there be more information.
Related
As mentioned in the RFC3501 the max value of UID assigned to each mail is "4,294,967,296 (Non-zero unsigned 32-bit integer)", so what would happen if that UID value is crossed?
I am planning to fetch emails from IMAP server based on last UID fetched
imap.fetch(`${lastUID}:*`,cb)
As I understand, fetching mails using the last UID logic is most inclusive way of fetching new or recent mails for all type of email accounts (Gmail, Outlook) since Gmail does not allow the use of \Recent flag. So what will be the case when the UID reaches its maximum value and how can that situation be handled?
As many others, I have an app with chat functionality. I have a StreamBuilder<QuerySnapshot> that listens to new chat messages, and a ListView.builder that shows them. I'm looking for a good way to paginate the messages, but none of the solutions I have found works for me, since I always have to listen to new messages.
One of the things I tried was this code, but that didn't seem to work even if the author said he had updated the code.
Each chat message has it's own document in a collection, so right now I just fetch all the documents in the collection and order them by a time field. However this only works for about 20 messages before performance suffers, so I would be very glad if someone could help me with this.
I guess you are showing the messages sorted by creation date, right? Why dont you paginate using the date then?
chatcollectionref.
where("creationdate", "<", enddate)
... // Add more conditions if needed
.orderBy("creationdate","desc").limit(20).get()
Start with enddate far in the future then update it to the creation date of the last message you retrieve and just paginate.
EDIT: a bit more details...
First run of the query: enddate = new Date(2100, 1, 1) and you get the first 20 messages and display them
The user scrolls down and reach the last message
Run again the query: enddate = creationdate of the last message you have already retrieved, and you get the 20 next
Loop back to 2
Works well in my chat app
I am a First time user of StackOverFlow here!
I have been trying to figure this out for two days and have come up short.
We have a form that displays every single Client / Customer that we have at the firm, in a continuous form view.
We want to be able to display on this form the date, for each client, when we last communicated, or called, the client. (We want to be sure that we prevent a situation where we have not called a client for more than 1.5 months).
I have a query on a table tracking our correspondence, and other activities, regarding our clients that, in SQL, looks like:
' Query ContactCommunications
SELECT Context, ID, NoteDate, ContactID
FROM Comments
WHERE (((Context)="Communication with Client" Or (Context)="Phone Call with Client"));
(ContactID is a secondary key for Contacts table - we are tracking not
only clients but also opposing parties and such)
This is intended to show all the dates we called or communicated with our clients.
I have a second query that then gets the Last Date from this table, grouped by ContactID, which looks like:
' Query qryLastCommunicationAgg
SELECT ContactID, Last(CommentDate) AS LastOfCommentDate
FROM Comments INNER JOIN qryContactCommunications
ON Comments.ID = qryContactCommunications.ID
GROUP BY Comments.ContactID;
My question is how do I get the query result (When we last called each client) into a text field in our Continuous form list? At the moment there will be some null values as well.
I have tried the expression:
=DLookUp("CommentDate","qryLastCommunicationAgg",[ID]=[ContactID])
But it does not work, giving me #Name?
Not sure what I did wrong. :-(
I appreciate greatly any assistance or suggestions!
-Glenn
First, use Max:
SELECT ContactID, Max(CommentDate) AS LastOfCommentDate
Then try with:
=DLookUp("LastCommentDate","qryLastCommunicationAgg","[ID]=" & [ContactID] & "")
("Below is the fixed version of the DLookup script - Glenn")
=DLookUp("LastOfCommentDate","qryLastCommunicationAgg","[ContactID]=" & [ID] & "")
In order to include information (like an order number) in a survey using an Email Collector, it's my understanding that this information needs to be stored in the Contact's custom variables. My concern is what happens if I am sending something like a customer satisfaction survey that needs to reference the order number, and the same customer (email address) places more than one order, and I have to send out more than one survey.
Will the custom values that are returned with the collectors/.../responses API call include the custom values at the time of the survey invite? Or will these be set to current values?
The custom values are stored on the response at the time the survey is taken. So if they change later, they will not change on the response. This will work fine as long as you don't sent out another survey with new custom values to the same contact before they respond to the previous one.
Just an FYI, there is also an option to set extra_fields on a recipient when adding recipients to an email collector (rather than on the contact).
POST /v3/collectors/<collector_id>/messages/<message_id>/recipients
{
"email": "test#example.com",
"extra_fields": {
"field1": "value1",
"field2": "value2"
}
}
I don't believe that data is stored with he response, but the recipient_id is and you can fetch the recipient by ID to get that data back.
Those are two options, you can see which one works best for you. The benefit of contact custom values is that you can view them and edit them from the web, whereas extra_fields are API only fields.
Once someone clicks on the fulfill button on the Sales Order I want it to send an email to someone.How can make this occur in Netsuite?
You can create a custom workflow on sales order and configure the worflow to send email to the specific email id. The email id can be either custom one / a field value from the sales order record (ex. customer, salesperson etc.,)
The condition for the workflow will be
OldRecord.Status!="Pending Fulfillment" && NewRecord.Status!="Pending Fulfillment"
Thanks
Frederick D
you can write a user event on Item Fulfillment record type and send email using nlapiSendEmail()
You may want to put a check in script if type == 'create' to avoid sending email on other record operation.