I am working on an app that needs to get a list of the recent messages in gmail by all senders in the inbox. For example I have 20 emails from "foo#bar.com" but I only want to fetch the last email sent by this email. I can not find any query or filter provided by google for this task. I tried fetching all emails in inbox and then process the data in the back-end, but it is a heavy work when there is a lot of emails fetched
Thank you
Try this:
function lastEmail(){
var userId = Session.getActiveUser().getEmail();
var userEmail = "USER_ID";
var optionalArgs = {
q:userEmail
}
// Threads[0] will get the most recently updated thread.
var mail = Gmail.Users.Threads.list(userId, optionalArgs).threads[0];
Logger.log(mail);
var message = GmailApp.getThreadById(mail.id).getMessages();
Logger.log(message[message.length-1].getBody());
}
I played around with the API and figured a way to do what you want. You need to enable the Gmail Google Advanced Service for this to work. You can have the userEmail be retrieved from your Sheet easily working with the range you want and SpreadsheetApp. One final thing is that to get the last message of the thread (the newest one) you'll have it at message[message.length-1].
Related
I have 5 users, they all look the same in Office 365 (from what I can see anyway) and have Teams Exploratory licences. I am able to create online meetings (OnlineMeetingProvider="teamsForBusiness" and IsOnlineMeeting=true) for 2 of them. For the other 3 users it doesn't error but doesn't create an online meeting (creates an event?), the response OnlineMeetingProvider is "unknown" and the OnlineMeeting is null. It is the same code so has to be a setting somewhere (all i do is change the id of the user).
The code used to create the request:
// Create client
var graphServiceClient = CreateGraphClient();
// Build event
var newEvent = new Event()
{
Subject = subject,
Body = new ItemBody() { ContentType = BodyType.Text, Content = body },
Start = startDate,
End = endDate,
IsOnlineMeeting = true,
Attendees = attendees == null ? null : GetAttendees(attendees),
OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness
};
The erroneous response:
Anyone have any idea what is going on?
Had the same problem, I had to add these permissions to the app I was using to create the meeting events:
TeamSettings.Read.All, TeamSettings.ReadWrite.All
As soon as I added them, isOnlineMeeting was correctly set to true, and onlineMeetingProvider was set to teamsForBusiness, as specified in the request.
onlineMeetingUrl is always null, but it's possible to get the meeting url from the "onlineMeeting.joinUrl" property, which is automatically populated by the API.
UPDATE:
As #lokusking pointed out, even if this is correct, it looks like it does not completely solve the problem. According to my tests, creating a Team event for a new user and getting isOnlineMeeting=true and onlineMeeting properly populated in the response will work only a couple of hours after the user account is created. Note that even with a fresh user the event IS created, just those properties won't contain the right values.
You can change an existing event to make it available as an online meeting, by setting isOnlineMeeting to true, and onlineMeetingProvider to one of the online meeting providers supported by the parent calendar. The response includes the updated event with the corresponding online meeting information specified in the onlineMeeting property.
https://learn.microsoft.com/en-us/graph/outlook-calendar-online-meetings?tabs=http#example-update-a-meeting-to-make-it-available-as-an-online-meeting
I'm trying to use Youtube Api V3 to get documentaries videos, unfortunately I can't get any results for many searched keys.
Is there any advanced configuration I can use to get more results or is there any alternative API(s) ?
this is my query
https://www.googleapis.com/youtube/v3/search?part=snippet&q=alien&type=video&videoCategoryId=35
First and foremost make sure you have an API_KEY. Follow link for details, then go to developer console to get one.
Then your request URL should look like this.
var API_KEY = "your api key";
var channelID = "The channel id u wan to pull";
var result = 30 // Limit the number of videos
`https://www.googleapis.com/youtube/v3/search?key=${API_KEY}&channelId=${channelID}&part=snippet,id&order=date&maxResults=${result}`
With an API key, I also pulled 0 results for 'alien' in the Documentary category. Perhaps there aren't any.
I have a contact us form developed in Kentico CMS, with Google reCaptcha (One checkbox with "I'm not a robot" challenge) integrated.
I keep getting form submissions with new details, mainly advts for online pharma pills and loans.
I am adding words from these submissions to a list of entries. The list of entries are validated against, and any new form submission with these words is blocked.
The contact us input text keeps changing.
I have tracked the IP and browser properties. The below properties are from junk mails.
The IP is not repeated for most submissions.
The browser info is of the sort
Name = Firefox,Type = Firefox37,Version = 37.0,....Platform = Win2000,Is Beta = False,Is Crawler = False,....,Is Win32 = True,...,Supports Cookies = True,....Supports JavaScript = ,3.0,...
or
Name = Chrome,Type = Chrome63,Version ....Platform = WinNT,.......,Supports JavaScript Version = 1.7
Is the reCaptcha broken, or is it an actual person browsing the site and making these submissions?
How can I find out, and avoid these submissions?
I am looking for a solution to send automated emails from my website to PHPList lists. From my understanding, PHPList's emails are authored manually using the web-based interface provided by the application. Are there some APIs I can use to allow my website to send emails directly?
You can just code one like this, just need to change some of the values on the insert strings to match your list. So when someone creates and account on your website, you just call a routine like this and insert it into PHPLIST.
You can also do it with a trigger on your members table. The code below is VB.NET - but you can easily convert it to php.
Public Sub AddMemberToPHPList(ByVal vUserEmail As String)
Dim moConn As MySqlConnection
moConn = New MySqlConnection("server=*********;User Id=******;Password=*******;Persist Security Info=True;database=phplist;Ssl Mode=None;Allow User Variables=True;")
moConn.Open()
Dim oMySqlCommand As New MySqlCommand
oMySqlCommand.Connection = moConn
oMySqlCommand.Parameters.AddWithValue("email_address", vUserEmail.ToLower)
oMySqlCommand.Parameters.AddWithValue("uniqid", Guid.NewGuid)
oMySqlCommand.CommandText = "INSERT IGNORE INTO phplist_user_user set email = ?email_address, confirmed=1,entered = now(),modified = now(),uniqid = ?uniqid,htmlemail = 1, bouncecount=0,disabled = 0"
oMySqlCommand.CommandType = CommandType.Text
oMySqlCommand.ExecuteNonQuery()
oMySqlCommand.CommandText = "INSERT IGNORE INTO phplist_listuser set userid = (select id from phplist_user_user where email = ?email_address) , listid = 3, entered = now(), modified= now()"
oMySqlCommand.ExecuteNonQuery()
End Sub
first, if is a list of emails, yo need use queues, you only need have the emails stored in a database, and then sending through queues with a cicle of the emails of the database
This reply is rather late I realize, but I think you'd do well to look into this plugin for PHPList:
https://resources.phplist.com/plugin/submitbymail
The plugin page says that the author is no longer supporting/developing the plugin, but the code that is there should work on current versions of PHPList.
I used to use an older plugin (called 'MailToList') for this exact purpose - someone can compose an email somewhere else, send it to a specific address on their system, and then the plugin watches those email inboxes for new emails and will queue up a new 'campaign' using that email as the source. So you essentially have to set up one email inbox for each list you want to send out to in PHPList.
(I'm just going through an upgrade process on my PHPList system and will probably use this 'SubmitByMail' plugin since the 'MailToList' plugin appears to not exist any more. But I haven't yet actually used the 'SubmitByMail' plugin.)
I need to get all contacts from Microsoft Exchange.. Those contacts are also saved in Office365 -> People -> Directory. Many thx for help!
Use the ResolveName("SMTP:") API to retrieve all the contacts from Global Address List, the limitation of such is it only returns the top 100 from the query operation.
Your Managed EWS code works similar to
var nameResolutionCollection = service.ResolveName("SMTP:");
foreach(var item in nameResolutionCollection)
{
// your code in here
}
Find out more information from
https://msdn.microsoft.com/en-us/library/office/aa563518%28v=exchg.150%29.aspx.