使用gmail api ios回复邮件

时间:2016-02-22 09:36:22

标签: ios objective-c gmail gmail-api

我正在处理邮箱应用程序,我正在尝试回复邮件。

我已经完成了文件。

 GTLQueryGmail *query = [GTLQueryGmail queryForUsersMessagesSendWithUploadParameters:nil];
query.message = gtlGmailMessage; //parent message
[self.service executeQuery:query
                  delegate:self
         didFinishSelector:@selector(displayResult:finishedWithObject:error:)];

我需要知道在gtlGmailMessage中需要做的所有更改才能回复父邮件。

先谢谢。

1 个答案:

答案 0 :(得分:0)

得到了解决方案。

我们必须用原始领域做所有事情。

GTLQueryGmail *query = [GTLQueryGmail queryForUsersMessagesSendWithUploadParameters:nil];
NSString *strRaw = [NSString stringWithFormat:@"To:%@\nSubject:%@\nThreadId:%@\nReply-To:%@\n\n\n%@",strToBeRep,mail.subject,mail.threadId,strToBeRep,msgToBeSend];
NSData *messageBody = [strMessageBody dataUsingEncoding:NSUTF8StringEncoding];
GTLGmailMessage *message =[[GTLGmailMessage alloc]init];
query.userId = @"me";
NSString *base64Encoded = [messageBody base64EncodedStringWithOptions:0];

message.raw = base64Encoded;

message.snippet = @"sadfasdfasd dafvasdvas dafvasdv";
base64Encoded = [base64Encoded stringByReplacingOccurrencesOfString:@"/" withString:@"_"];
base64Encoded = [base64Encoded stringByReplacingOccurrencesOfString:@"+" withString:@"-"];
message.threadId = self.mail.mail.threadId;
query.message = message;

[self.service executeQuery:query
                  delegate:self
         didFinishSelector:@selector(displayResultForNewMessage:finishedWithObject:error:)];


- (void)displayResultForNewMessage:(GTLServiceTicket *)ticket finishedWithObject:(GTLGmailMessage *)emailsResponse error:(NSError *)error
{    
if(!error)
    NSLog(@"Success");
}