.Net에서 GMail API를 사용 중입니다. Net.Mail.MailMessage를 사용하여 메시징 작성. 그런 다음 MimeKit을 사용하여 MimeMessage를 만듭니다 (첨부 파일 + HTML 메시지 보내기를 사용하여). Base64 인코더에 MimeMessage.ToString을 전달합니다. API 오류가 없습니다. 코드가 정상적으로 실행됩니다. Gmail의 보낸 페이지에서 메시지를 볼 수 있습니다. Mail은 완벽하게 보입니다 (실제로 send는 메시지 id를 반환합니다). Gmail에는이 메일에 다음과 같은 추가 메시지가 있습니다.Gmail API 이메일 수신 거부
Bounce <[email protected]>
An error occurred. Your message was not sent.
평소와 마찬가지로 Google의 다른 정보는 없습니다. 이 문제를 해결하는 방법?
Dim msg = New Net.Mail.MailMessage
msg.Subject = subject
msg.To.Add(New MailAddress(ToEmail))
msg.From = New MailAddress(FromEmail, SenderName)
msg.ReplyTo = New MailAddress(FromEmail, SenderName)
msg.Body = bodyText
msg.IsBodyHtml = True
If Not String.IsNullOrWhiteSpace(fileAttachment) Then
If System.IO.File.Exists(fileAttachment) Then
Dim Attachment As New Net.Mail.Attachment(fileAttachment, "application/pdf")
msg.Attachments.Add(Attachment)
End If
End If
Dim message As MimeMessage = MimeMessage.CreateFromMailMessage(msg)
Dim newMsg = New Google.Apis.Gmail.v1.Data.Message()
newMsg.Raw = Base64UrlEncode(message.ToString)
GmailService.Users.Messages.Send(newMsg, "me").Execute()
Private Function Base64UrlEncode(ByVal input As String) As String
Dim inputBytes = System.Text.Encoding.UTF8.GetBytes(input)
'Special "url-safe" base64 encode.
Return Convert.ToBase64String(inputBytes).Replace("+", "-").Replace("/", "_").Replace("=", "")
End Function
이것은 반송 메시지입니다. 보시다시피 모든 것이 괜찮아 보입니다. Google API로 작업하는 것이 가장 실망 스럽습니다.
200 OK
- Hide headers -
cache-control: no-cache, no-store, max-age=0, must-revalidate
content-encoding: gzip
content-length: 85
content-type: application/json; charset=UTF-8
date: Sat, 24 Jan 2015 05:57:21 GMT
etag: "96Z6JVARoyR8skov3RseF4DCFpA/mFWFskkdSFxyjIhRJHJuhDCBvfY"
expires: Fri, 01 Jan 1990 00:00:00 GMT
pragma: no-cache
server: GSE
vary: Origin, X-Origin
{
"id": "14b1a841e4fff910",
"threadId": "14b1a841e4fff910",
"labelIds": [
"SENT"
]
}
시도가가 [API 탐색기]에서 실행 얻을 수 (https://developers.google.com/gmail/api/v1/reference/users/messages/send#try-it) 첫째, 참조 http://stackoverflow.com/a/24461102/1545993 – Taifun
API 탐색기에서와 동일한 결과가 나타납니다. 메시지는 전달되지만 배달되지 않습니다. 네, 그 페이지를 읽었습니다. 나는 그것을 정확하게하고있다. 내 문제는 형식에 뭔가 잘못이있는 경우, GMail API는 예외를 throw해야합니다. 또한 Gmail 전송 폴더를 체크인 할 때 메일이 완벽하게 보입니다. 즉, 데이터 구조와 형식이 잘되었음을 의미합니다. 이 뛰어난 Google 개발자와 연락 할 수있는 방법이 있습니까? –
예제 메시지를 사용하여 base64로 인코딩 한 다음 동일한 결과를 얻으면 API 탐색기를 사용하여 먼저 실행하십시오. – Taifun