如何使用c#或python发送所有gmail草稿 - c#

我总是使用gmail保存网络剪辑或便笺。我只是创建一个新邮件,对其进行编辑并另存为草稿。两年多来,我已经在Gmail草稿文件夹中转储了1000多个邮件。我想以编程方式将所有这些都发送给我自己。我做了一些研究,现在我可以使用python或c#通过IMAP加载我的gmail收件箱消息,或者创建邮件并通过SMTP发送。但是,我仍然无法阅读消息草稿并将其发送给我自己。

(为什么我将GMail用作便笺存储,而不是诸如Evernote,MS onenote或Apple note等便笺应用程序?因为在任何平台或设备上都更好地支持电子邮件。通常有预装的电子邮件客户端,查找或查找电子邮件更容易。定义一个“创建新邮件”键盘快捷方式,而不是定义一个“导出到Evernote”键盘快捷方式。)

参考方案

如果使用MailKit,请按照以下步骤操作:

using System;
using System.Net;
using System.Threading;

using MailKit.Net.Imap;
using MailKit.Net.Smtp;
using MailKit;
using MimeKit;

namespace TestClient {
    class Program
    {
        public static void Main (string[] args)
        {
            using (var client = new ImapClient ()) {
                var credentials = new NetworkCredential ("jimbo", "password");

                client.Connect (new Uri ("imaps://imap.gmail.com"), CancellationToken.None);
                client.Authenticate (credentials, CancellationToken.None);

                var folder = client.GetFolder (SpecialFolder.Drafts);
                folder.Open (FolderAccess.ReadWrite, CancellationToken.None);

                using (var smtp = new SmtpClient ()) {
                    smtp.Connect (new Uri ("smtps://smtp.gmail.com"), CancellationToken.None);
                    smtp.Authenticate (credentials, CancellationToken.None);

                    var indexes = new int[folder.Count];
                    for (int i = 0; i < folder.Count; i++) {
                        var message = folder.GetMessage (i, CancellationToken.None);

                        // if you haven't already specified a recipient, do it now:
                        message.To.Add (new MailboxAddress ("Jimbo", "[email protected]"));

                        smtp.Send (message, CancellationToken.None);
                        indexes[i] = i;
                    }

                    // if you also want to delete the messages on the IMAP server:
                    folder.AddFlags (indexes, MessageFlags.Deleted, true, CancellationToken.None);
                    folder.Close (true, CancellationToken.None);

                    smtp.Disconnect (true, cancellationToken.None);
                }

                client.Disconnect (true, cancellationToken.None);
            }
        }
    }
}

如何在Wiremock中为JUNIT匹配精确的json - java

我正在使用Wiremock在Spring启动应用程序中模拟Junit的REST服务。我的问题是,我无法匹配多个匹配模式。 Junit.javaStringValuePattern pattern = WireMock.matching(".*"); givenThat(post(urlEqualTo("/softwares�…

当回复有时是一个对象有时是一个数组时,如何在使用改造时解析JSON回复? - java

我正在使用Retrofit来获取JSON答复。这是我实施的一部分-@GET("/api/report/list") Observable<Bills> listBill(@Query("employee_id") String employeeID); 而条例草案类是-public static class…

改造正在返回一个空的响应主体 - java

我正在尝试使用Retrofit和Gson解析一些JSON。但是,我得到的响应机构是空的。当我尝试从对象中打印信息时,出现NullPointerException。我确保URL正确,并且我也确保POJO也正确。我正在使用jsonschema2pojo来帮助创建POJO类。这是我要解析的JSON{ "?xml": { "@versi…

每个文件合并后添加换行 - python

我有很多类似以下内容的JSON文件:例如。1.json{"name": "one", "description": "testDescription...", "comment": ""} test.json{"name"…

Mongo汇总 - javascript

我的收藏中有以下文件{ "_id": ObjectId("54490b8104f7142f22ecc97f"), "title": "Sample1", "slug": "samplenews", "cat": …