0

我们不允许使用本机邮件功能来发送电子邮件。

因此,我们的原生 iPad 应用程序集成了 MSGraph SDK,用于发送邮件和附件。MSGraphSDK 用于通过获取身份验证凭据来验证工作用户。

NSArray *scopes = [kScopes componentsSeparatedByString:@","];
[self.authProvider connectToGraphWithClientId:kClientId scopes:scopes completion:^(NSError *error) {
                    if (!error) {
                        NSLog(@"Authentication successful.");
                        [self sendMailWithAttachments];
                    }
}];

从下一次开始,它将直接发送邮件而不询问工作凭据。

[MSGraphClient setAuthenticationProvider:self.authProvider.authProvider];
self.graphClient = [MSGraphClient client];

MSGraphMessage *message = [self getSampleMessage];
MSGraphUserSendMailRequestBuilder *requestBuilder = [[self.graphClient me]sendMailWithMessage:message saveToSentItems:true];
MSGraphUserSendMailRequest *mailRequest = [requestBuilder request];
[mailRequest executeWithCompletion:^(NSDictionary *response, NSError *error) {
        if(!error){
}
}];

如果用户未通过身份验证或用户身份验证不成功,MSGraph SDK 用于自动引导经过身份验证的页面。

现在的问题是,用户正在尝试验证自己并在前几次成功发送邮件。在那之后一个月或更长时间,他们尝试使用这个应用程序发送邮件。不幸的是,它没有任何反应。

4

1 回答 1

-1

试试下面的代码:

NSString *titleEmail =  @"Your title";
NSString *msgBody = @"PFA";
NSArray *toRecipents = [NSArray arrayWithObject:@"xyz@gmail.com"];

NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, self.view.bounds, nil);
UIGraphicsBeginPDFPage();
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndPDFContext();

MFMailComposeViewController *mailComposeVC = [[MFMailComposeViewController alloc] init];
mailComposeVC.mailComposeDelegate = self;
[mailComposeVC setSubject:titleEmail];
[mailComposeVC setMessageBody:msgBody isHTML:NO];
[mailComposeVC addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"MY.pdf"];
[mailComposeVC setToRecipients:toRecipents];

[self presentViewController:mailComposeVC animated:YES completion:NULL];
于 2019-05-16T10:59:08.347 回答