Tag: Gmail中的API

使用Google Script永久删除我的电子邮件的脚本

这个Gmail.Users.Messages.remove(userId,id)如何工作? 电子邮件的ID是什么,是永久删除电子邮件的正确function吗? 在我的情况下,我想立即删除我发送的所有电子邮件。 这是我从某人那里拿来的一些代码,只有不同的标签: function myFunction() { var threads = GmailApp.search(“in:sent label:Inbox”); var me = Session.getActiveUser().getEmail(); for (var i = 0; i < threads.length; i++) { Gmail.Users.Messages.remove(me, threads[i]); } } 无论如何这是正确的,任何人都可以帮助我吗? 编辑:我修改了我的代码,但它仍然无法正常工作,我仍然无法弄清楚如何使用函数remove,这是它: function myFunction() { var me = Session.getActiveUser().getEmail(); var thread = Gmail.Users.Threads.list(me); for (var i = 0; i < 1000; i++) { Gmail.Users.Threads.remove(me, thread); […]

Gmail api范围和格式不匹配

我正在尝试为android编写一个小小的gmail客户端作为培训。 我从https://developers.google.com/gmail/api/quickstart/android中获取了gmail api指南示例,对其进行了一些修改以获取带有标题和正文的消息。 我将范围设置为GmailScopes.Gmail_modify并编辑了主请求函数,如下所示: private List getDataFromApi() throws IOException { // Get the labels in the user’s account. String user = “me”; List labels = new ArrayList(); ListLabelsResponse listResponse = mService.users().labels().list(user).execute(); ListThreadsResponse listThreads = null; try { listThreads = mService.users().threads().list(user).execute(); } catch (IOException ioex){ Log.e(LOG_TAG, “First: ” + ioex.toString()); } for (Thread thread : listThreads.getThreads()) […]

通过Gmail API发送包含纯文本后备的HTML电子邮件

StackOverflow上一个已回答的问题表明,在电子邮件正文中添加html-markup就可以了。 这个解决方案是否正确 但是,如果收件人的电子邮件服务器/客户端不支持HTML电子邮件呢? 例如,当使用Apache commons电子邮件时 ,我会执行以下操作: // set the html message email.setHtmlMsg(“Our logo – “); // set the alternative message email.setTextMsg(“Your email client does not support HTML messages”); 如果收件人电子邮件服务器/客户端不支持HTML,有没有办法告诉Gmail API哪些电子邮件可以回复? PS我对Java代码示例特别感兴趣。 谢谢

如何在Gmail中获取完整的邮件正文?

我想获得完整的消息体。 所以我尝试: Message gmailMessage = service.users().messages().get(“me”, messageId).setFormat(“full”).execute(); 为了获得身体,我尝试: gmailMessage.getPayload().getBody().getData() 但结果总是为null 。 如何获得完整的邮件正文?

GMail REST API:使用没有模拟的Google凭据

是否可以在不使用模拟的情况下使用Google Credentials for GMAIL REST API? 在GMAIL REST API的许多示例中,我看到必须使用与域和Google APPS关联的模拟帐户。 我只想使用GMAIL REST API api服务器到服务器: FE: GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport) .setJsonFactory(jsonFactory) .setServiceAccountId(serviceAccountUserEmail) **.setServiceAccountUser(“myuser@mydomain.com)** .setServiceAccountScopes(SCOPES) .setServiceAccountPrivateKeyFromP12File( new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH)) .build(); 问题是,我没有任何域名,我只使用GMAIL帐户…但我没有任何方式授权,例如:MyMainGmailAcccoun@gmail.com servive acccount id 4xxxxxxxxxxxxxq@developer.gserviceaccount.com“;是使用MyMainGmailAcccoun@gmail.com创建的” 客户帐户“ 这没有任何意义,我不想冒充其他域名的其他帐户,我也没有办法对myMainGmailAcccoun@gmail.com进行authozize。 只是有效,如果您有一个帐户来冒充与Google Apps相关的其他域名,并获得Google Apps …您需要一个域名。 任何建议?

使用Google Spreadsheet API在Google中的Google驱动器中创建电子表格

我创建了一些填充谷歌电子表格的工具。 它工作正常1年,因为今天我错了 Exception in thread “main” com.google.gdata.util.AuthenticationException: Error authenticating (check service name) at com.google.gdata.client.GoogleAuthTokenFactory.getAuthException(GoogleAuthTokenFactory.java:688) at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:560) at com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:397) at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:364) at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:319) at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:303) 这是与gmail连接的代码部分: String USERNAME = “usename@……..com”; ->of course I’m using proper username and password String PASSWORD = “*******”; SpreadsheetService service = new SpreadsheetService(“SandboxCheck”); service.setUserCredentials(USERNAME, PASSWORD); 我不知道如何连接gmail,我试图通过oAuth这样做,但我不知道如何做到这一点。 在https://developers.google.com/google-apps/spreadsheets/authorize上的示例中,只有.net的代码。