MFMailCompser is sending 'noname' attachment randomly - ios

A client of mine is having an issue where he'll use our app to send an email with an auto generated PDF that's attached to the email and sometimes it will work and sometimes it will not.
Things We've noticed:
When sending from his gmail account, it typically fails and the email is sent out with a blank message and an attachment that reads 'noname'.
Sometimes, when selecting his personal email, the app still sends the email from his gmail account. I was able to reproduce this on an iPad Pro and can verify that when I select one email, it shows it was sent from another.
Removing the gmail account from the iPad and readding it back usually
fixes the problem for the first email sent and then it goes back to
the normal problem stated in the first bullet.
Here is the code where I create the MailComposer view:
func configureMailComposeViewController() -> MFMailComposeViewController {
let mailComposerViewController = MFMailComposeViewController()
mailComposerViewController.mailComposeDelegate = self
if let fileData = NSData(contentsOfFile: GeneratePDF.attachEachPage()) {
mailComposerViewController.setSubject(Constants.EmailPreferences.subject)
mailComposerViewController.setMessageBody(Constants.EmailPreferences.message, isHTML: true)
mailComposerViewController.addAttachmentData(fileData, mimeType: "application/pdf", fileName: "overview")
}
return mailComposerViewController
}
The view opens up no problem, There's a title, body message, and an attachment. Yet, when received everything's been stripped except the title. The PDF is < 6MB and only has 5 pages.

Related

Docusign iOS SDK directly sending envelope without opening anything also not asking to do the signature

I have created a template in docusign web and using its template id, i am calling the function from iOS SDK.
TemplatesManager.sharedInstance.displayTemplateForSignature(templateId: templateId, controller: self, tabData: tabData, recipientData: recipientData, customFields:customFields, onlineSign: onlineSign, attachmentUrl: attachmentUrl) { (controller, errMsg) in
print(errMsg)
}
The recipient data i am sending is
let recipientDatum = DSMRecipientDefault()
// Use recipient roleName (other option to use recipient-id) to find unique recipient in the template
recipientDatum.recipientRoleName = "Client"
recipientDatum.recipientSelectorType = .recipientRoleName
recipientDatum.recipientType = .inPersonSigner
// In-person-signer name
recipientDatum.inPersonSignerName = "Akshay Somkuwar"
// Host name (must match the name on the account) and email
recipientDatum.recipientName = "Akshay Somkuwar"
recipientDatum.recipientEmail = "akshay.s.somkuwar#gmail.com"
let recipientData: Array = [recipientDatum]
Same recipient is added for template in docusign website
Also i have added observers for DSMSigningCompleted and DSMSigningCancelled to get envelopeId.
Now when i am calling this function displayTemplateForSignature no screen is opening to show the PDF or To sign the PDF, without asking for signature, the envelope is directly sent to the recipient. and i am getting this response in console with notification.
name = DSMSigningCompletedNotification, object = Optional(<Public_Adjuster.AgreementSignViewController: 0x110bb8060>), userInfo = Optional([AnyHashable("templateId"): 506346f5-7adb-4132-b15f-d288aa268398, AnyHashable("signingMode"): online, AnyHashable("envelopeId"): 2eeeeda8-5b74-4930-904e-94b2ce6451ac])
I want to open the pdf for the passed templateId but its not opening the pdf nor its asking for signature, and its directly sent to the recipient.
Any help will be appreciated, Thank you.
This behaviour, sending the envelope directly, is triggered when DocuSign SDK can not find any signers in the template/envelope that matches the logged-in user. Given that you are using the recipientDefaults, ensure that your signer information on the template (preset signer on the DocuSign web) matches the Account information exactly with the recipientDefaults object.
You may compare it with .
One issue I noticed is the signer type is set to need to sign which corresponds to a remoteSigner on the DocuSign web. And on the recipientDefaults object it's set as inPersonSigner. It should be .signer corresponding to DSMRecipientTypeSigner.
recipientDatum.recipientType = .signer.
Or you may change the need to sign to in person signer on the DocuSign web.
Another suggestion is to remove the name & email from the template screenshot shared and keep that empty as the client app is passing name & email with the recipientDefaults object to the SDK.
More details: How to set recipient defaults

Sending a SMS in app through MessageUI

Please help to solve the issue of sending invites to the app via SMS or iMessage.
The issue is that when all the receipents of the message have iMessage available (blue button), then upon invitation sending a group consisting of these people gets created, but I need to send the messages separately (not in group).
if MFMessageComposeViewController.canSendText() {
let messageViewController = MFMessageComposeViewController()
messageViewController.body = "Some invite text"
messageViewController.recipients = [phone_numbers_from_contacts]
messageViewController.messageComposeDelegate = self
self.present(messageViewController, animated: true, completion: nil)
} else {
// Some alert with text "SMS services are not available"
}
AFAIK you have no control over whether the message is sent as a group message or not.
If you want to send it as individual messages then I would suggest using multiple different instances of the MFMessageComposeViewController.
TBH though, you shouldn't really be using this for sending out spam texts anyway.

How to send a mail to more than 2000 recipient in iOS?

I have an option to "invite all" in my device contacts email to use my iOS application through MFMailComposeViewController. Its working fine right now. But i want to know the limitation of recipients can allow in a single mail from Apple. Herewith i added the code to send mails. Here contactList is an array. Assume like this array contains more than 2000 email id's.
#IBAction func act_InviteAllInContacts(sender: AnyObject)
{
var contactList : NSMutableArray = NSMutableArray()
contactList = addressBookClassObj.getContactNames()
var picker = MFMailComposeViewController()
picker.mailComposeDelegate = self
picker.setSubject("APPLICATION NAME")
picker.setMessageBody("Hi! Checkout this app https://itunes.apple.com/us/app***********", isHTML: true)
picker.setToRecipients(contactList as [AnyObject])
presentViewController(picker, animated: true, completion: nil)
}
Need advice: is it possible to send mails to all the recepient or message will be failure.
Apple's documentation does not refer to any limitation.
However, this is a VERY BAD practice to send an email to 2000 recipient!
You might be denied by your email provider
You might be black listed for spam
If you put your recipient list anywhere else than in the Bcc field (setBccRecipients:), everyone will have access to every email address in your list.
To send that amount of messages, you should really consider to use a Mailing Tool such as Mailchimp.
TL;DR: There might be no limitation, but please don't do that !

Send an email from my app without using MFMailComposeViewController

Is it possible to send an automatically generated email using my own email address to another email address of mine by clicking a button?
I tried to use MFMailComposeViewController but another view appeared. Can I do it without this view?
You can do it only by creating own server-side mailer. On button clicking you have to send request with all needed data (email address, body, subject, etc) and server will send mail.
If You want send directly from app - MFMailComposeViewController is the only LEGAL way
By default in iOS you can only use the MFMailComposeViewController, which uses the user's mail account. Therefore you cannot send fully automated mail messages (the user allways has to confirm/cancel).
libMailCore is a great iOS framework which allows you to generate and send mails without any user interferance. In that case you'll be using your own server/credentials (thus not the user mail account). There are apps in the App Store using mailcore, so i would guess it's legit.
Yes there is a way using Swift-SMTP.
Send email
Create a Mail object and use your SMTP handle to send it. To set the sender and receiver of an email, use the User struct:
let drLight = Mail.User(name: "Dr. Light", email: "drlight#gmail.com")
let megaman = Mail.User(name: "Megaman", email: "megaman#gmail.com")
let mail = Mail(
from: drLight,
to: [megaman],
subject: "Humans and robots living together in harmony and equality.",
text: "That was my ultimate wish."
)
smtp.send(mail) { (error) in
if let error = error {
print(error)
}
}

how to share a link via sms in blackberry

I am building an application where I need the option to share via email and SMS.
I have done the share via Email, where when the user selects the image, the url is passed as the content of the email. But while sharing via SMS, I can't do something like setContent as I did for email and fetch the url in the SMS directly, instead of user typing the address manually.
I am using Message class in email and MessageConnection class for SMS, as shown in the blackberry community example.
The Message object you receive when calling MessageConnection.newMessage(TEXT_MESSAGE) is actually a TextMessage object (or a BinaryMessage object with BINARY_MESSAGE).
If you cast the received object to the proper class (TextMessage or BinaryMessage), you should be able to use its setPayloadText(String data) (or setPayloadData(byte[] data) for a BinaryMessage) to enter a value in the message before sending it.
Your code should look like this:
Message msg = myMessageConnection.newMessage(TEXT_MESSAGE, /* address */);
TextMessage txtMsg = (TextMessage)msg;
txtMsg.setPayloadText(/* Text to send */);
myMessageConnection.send(msg);
When you send an email, you can set the body of it and send it to the user from the Email native application. You cant do taht for SMSs. I worked on that issue and for BB Torch I was able to set the text of the SMS message but for other devices that was impossible. I always obtain an empty text message!!
So y suggestion to you is using the following code wich will send the SMS to a number without the interference of the user
MessageConnection conn = (MessageConnection) Connector.open("sms://" + userNumber);
TextMessage txtmessage = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
txtmessage.setPayloadText(text);
conn.send(txtmessage);

Resources