Alternative to MFMailComposeViewController? - ios

is there an alternative to MFMailComposeViewController that has more-or-less the same functionality, but that will let me handle the sending of the email myself, outside of Apples email-sending system?
What I want to do is to provide a nice email dialog, and then send it through a CRM system instead of directly from the iPad.
Cheers
Nik

YES, You can use the MailCore Framework. You can handle the sending of email by yourself. Before sending the mail you have to set its fields such as To,CC,BCC,Subject,body etc and then send by the following code..
CTCoreMessage *msg = [[CTCoreMessage alloc] init];
[CTSMTPConnection sendMessage:msg server:[server stringValue] username:[username stringValue]
password:[password stringValue] port:[port intValue] useTLS:tls useAuth:auth];
[msg release];
It works for me fine. Hope it will help you..

You will need to create your own email view and handler. You can use something like JSTokenField : https://github.com/jasarien/JSTokenField to get the functionality on the mail "To:" field.

Related

Alternative way of sending e-mail from app on iOS 10 when Mail app is deleted?

Now that Apple's "Mail" app can be deleted in iOS 10 and using [MFMailComposeViewController canSendMail] is always return NO when Mail app is deleted.
Is there any alternative way for sending Mail from inside the app?
You can use the MailCore Framework. This is an alternative to MFMailComposeViewController. Using this framework you can send an email programmatically. You have to construct each and every field i.e, To,CC,BCC,Subject,body etc. by yourself using this. One important thing to remember it has no UI.
CTCoreMessage *msg = [[CTCoreMessage alloc] init];
[CTSMTPConnection sendMessage:msg server:[server stringValue] username:[username stringValue]
password:[password stringValue] port:[port intValue] useTLS:tls useAuth:auth];
[msg release];

iOS Autocomplete UITEXTVIEW | Add autocomplete suggestions dynamically

I've been trying to implement an autocomplete UITEXTVIEW for my email app using this
https://github.com/hoteltonight/HTAutocompleteTextField
I would like to add the email addresses dynamically though. Is there any way to achieve the same. Because when I checked, the email addresses are initialised at start as given below.
HTEmailAutocompleteTextField.m
- (void)setupAutocompleteTextField
{
[super setupAutocompleteTextField];
// Default email domains to suggest
self.emailDomains = #[ #"gmail.com", #"yahoo.com"];
self.autocompleteDataSource = self;
}
The above method is called from HTAutocompleteTextField.m[- (void)awakeFromNib] as soon as the app is launched thereby not letting me to add email addresses dynamically.
Is there any work around because I get my email addresses later.
Any help is much appreciated.
Have you tried this from GitHub readme
HTAutocompleteTextField *textField = [[HTAutocompleteTextField alloc] initWithFrame:CGRectMake(0,0,100,31)];
The data source is the brains of the autocomplete logic. If you just want to autocomplete email addresses, use HTAutocompleteManager from the example project as follows:
textField.autocompleteDataSource = [HTAutocompleteManager sharedManager];
textField.autocompleteType = HTAutocompleteTypeEmail;
Alternatively, you may wish to create your own data source class and user the autocompleteType property to differentiate between fields with different data types. A HTAutocompleteTextFields's data source must implement the following method, as part of the HTAutocompleteDataSource protocol.
-(NSString *)textField:(HTAutocompleteTextField *)textField completionForPrefix:(NSString *)prefix ignoreCase:(BOOL)ignoreCase

No HardCoded "fromEmail" (Sender) in SKPSMTPMessage

I have been trying to use SKPSMTPMessage library.Although i have not yet succeeded would anyone let me know how i do not require to hardcode the sender of the mail.
What i have seen is we need to hardcode the sender in order to send the mail in SKPSMTPMessage. something like this :
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = #"youremail#email.com";
But i don't want a particular sender rather it should be the sender from the device.
Similar to one we have in mfmessagecomposeviewcontroller.
Also can i have the sender included in "CC/BCC" portion so as the sender as well receive's the copy of the mail he/she has sent.
Thank You.
You can achieve this, here are the base-steps:
- Create a screen/view which will collect all these informations (FromEmail, ToEmail, CC, BCC, SMTP Address, etc.)
- Save those details in your code.
- Use those details while sending out mail.
Hence it will make your code look like:
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = fromEmailTextField.text;
Hope this helps.

MSTextView is not detecting some of the URLs

I added MSTextView in my project. It is working fine in every manner except some of the links e.g. http://www.t-mobileadvantagedirect.com/L.aspx?d=Vb4UseqIl9QYojIAqfjNqw==. I am not having any idea of link regex. Please help me...I finished my whole app, only this issue is bothering me..
In line 190 of MSTextView.m, return the following instead:
return #"(\\bhttps?:\\/\\/[-A-Z0-9+&##\\/%?=~_|!:,.;]*[-A-Z0-9+&##\\/%=~_|])";
You also need to specify the NSRegularExpressionCaseInsensitive option when creating the NSRegularExpression object.
Also, be a good person, fork the repository, make the changes in your fork and submit a pull request to the original author.
Source of the regular expression: https://stackoverflow.com/a/8943487/350272
I've no idea with the MSTextView, but I can help you! I believe that you've all URLs like in question, and it's not showing up with the textview, right?
What you've to do is,
Show normal url inside your text with MSTextView, something like,
Check out my website, here's the link, http://www.t-mobileadvantagedirect.com
okay, now in, MSTextViewdelegate,
You've to check for the URL tapped,
- (void) handleURL:(NSURL*)url
{
if([url.absoluteString isEqualToString:#"http://www.t-mobileadvantagedirect.com"])
{
WebViewController *webview = [[WebViewController alloc] initWithURL:[NSURL urlWithString:#"http://www.t-mobileadvantagedirect.com/L.aspx?d=Vb4UseqIl9QYojIAqfjNqw=="]];
[self.navigationController pushViewController:webview animated:YES];
[webview release];
}
}
I know this isn't a solution if you've the same domain url for multiple paths!

Links inside email message body

I need to modify an existing project. In this project there are several (many) places where the app sends an email with preset text within it. The used function is
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailString]];
Which obviously opens iOS Mail, ready to send the message.
Now I need to include links in the body of the messages. Is it possible to do it without switching to MFMailComposeViewController in all that places? How?
it is very simple.
Each html tag should appended, use front slash before double quote in the url beginning and end
Example :
NSString *bodyText =#"<html>";
bodyText = [bodyText stringByAppendingString:#"<head>"];
bodyText = [bodyText stringByAppendingString:#"</head>"];
bodyText = [bodyText stringByAppendingString:#"<body>"];
bodyText = [bodyText stringByAppendingString:#"<a href=\"http://www.devaski.com\">My blog"];
bodyText = [bodyText stringByAppendingString:#"</a>"];
[mailComposer setMessageBody:bodyText isHTML:YES];
Have a look at this document - https://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MailLinks.html#//apple_ref/doc/uid/TP40007892-SW1
The short answer, yes, you can pre-populate the body of the message by adding a body parameter to the URL (i.e mailto:john#apple.com?body=This%20goes%20to%20body). Notice though, that the string has to be properly escaped, which you can do easily with the help of NSString's stringByAddingPercentEscapesUsingEncoding:
I assume that any URL in the body that looks like a URL will be converted into a link by Mail app itself - not sure about that, test it out.

Resources