We are not allowed to use native mail functionality for sending emails.
Hence our native iPad app integrated MSGraph SDK for sending mails along with an attachment. MSGraphSDK used to verify the work user by getting authentication credentials.
NSArray *scopes = [kScopes componentsSeparatedByString:@","];
[self.authProvider connectToGraphWithClientId:kClientId scopes:scopes completion:^(NSError *error) {
if (!error) {
NSLog(@"Authentication successful.");
[self sendMailWithAttachments];
}
}];
From next time onwards, it will directly send the mails without asking work credentials.
[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 used to direct the authenticated page automatically if users are not authenticated or users authentication was not successful.
Now problem here is, users are trying to authenticate themselves and sending mails on first few times successfully. After that a month later or more, they trying to send the mails using this app. Unfortunately it does not respond anything.