C#Gmail-API发送请求空引用表达式

时间:2017-03-14 09:44:27

标签: c# .net email gmail-api google-api-dotnet-client

我正在尝试使用Gmail-API发送电子邮件,但收到Insufficient Permission。这是我的代码:

var msg = new AE.Net.Mail.MailMessage
            {
                Subject = "[ENC] " + textBox2.Text,
                From = [MyEmailHere],
                Body = textBox6.Text
            };

            msg.To.Add(new MailAddress(textBox1.Text));
            msg.ReplyTo.Add(msg.From);

 var msgStr = MimeMessage.CreateFromMailMessage(msg);

 var gmailMessage = new Google.Apis.Gmail.v1.Data.Message
            {
                Raw = Base64UrlEncode(msgStr.ToString())
            };
            UsersResource.MessagesResource.SendRequest request = service.Users.Messages.Send(gmailMessage, "me");
            request.Execute();

异常出现在最后一行。

我的示例RAW发送:

  

RnJvbTogcHBhbmFraW5AZ21haWwuY29tDQpSZXBseS1UbzogcHBhbmFraW5AZ21haWwuY29tDQpUbzogcHBhbmFraW5AZ21haWwuY29tDQpTdWJqZWN0OiBbRU5DXSBhZGRzDQpDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9dXRmLTgNCg0Kw6_Cv8K9PcOvwr_CvVrDr8K_wr0Jw6_Cv8K9w4LCtMOvwr_CvTobF8Ovwr_CvTw

其他问题:如何从凭据或授权中获取我的电子邮件地址?

0 个答案:

没有答案