How to send a link via MFMailComposer? - ios

My actual problem is to send a link with a YouTube-Adress per email with Swift.
I use MFMailComposer and sure, it´s no problem to attach a file. But a link?
Is there any way to attach a link only, so the receiver can click the link that calls the YouTube-Page???

Just use HTML for that purpose:
// Add your body in a HTML format
let body = "<p>This is a test. Check out the link to youtube</p> YouTube"
// In your mail instance in setMessageBody, add your body and set isHTML to true
mail.setMessageBody(body, isHTML: true)
Update
If you don´t need a placeholder you could just add http://... URL in the email text as #rmaddy commented.

Related

how to create a zendesk ticket with inline image

I would like to create a ticket with inline image but cannot get through it. I am using a rich text having a pasted screen capture image, the content is like
"<img ..."
By using ZendeskApi_V2, I set the Ticket's Comment HtmlBody with the content mentioned but did not work, neither of PlainBody or Body.
Anyone can help, please.
For instance:
In my application, an image is inserted into a RadEditor
By setting the Ticket.Comment as
var ticket = new Ticket {
Comment = new Comment {
HtmlBody = HttpUtility.HtmlDecode(RadEditor.Content)
}
}
After sending the Create Ticket request, I cannot see the inline image in the Zendesk dashboard.
So, did I do it in a right way? How should an embedded or inline image be sent through Zendesk API?
You may need to upload the attachment file first, then you can set the attachment's token in the comment. See here - https://developer.zendesk.com/rest_api/docs/support/tickets#attaching-files

How to parse email message as html format when there is no attachment

I am new in using IMAP. Now I am trying to use IMAP to see my emails in my web page from mail server. I have configured the settings. And I think the configuration is ok. Now I want to show the message body as html format. My code is:
// getting email body text
if($attachments[1]['is_attachment']!=""){ // if attachmentavailable.
$part_number = '1.2';
}
else{
$part_number = '1';
}
$message = quoted_printable_decode(imap_fetchbody($inbox, $email_number, $part_number));
When email has attachment, it is showing as html format. But when there is no attachment the message is showing as plain text. There is no bold or any other formatted font if I give and there is no link also.
If I use part number 1.2 in else part no message is shown.
Now how can I print email message as html format where there is no attachment.
Learn about the BODYSTRUCTURE format. E-mails can come up in about a ton of different structures, and unless your application actually takes a look at the structure of the MIME message, your code is blindly guessing what to do.

Mailto template works when "paste in urlbar" but not after "registration and click on mailto link"

This is the weirdest thing. I have a Hotmail/Live mail/Outlook mail account. So the template to start composing an email is this:
http://mail.live.com/secure/start?action=compose&to=%s
I have tested adding the Gmail handler template of https://mail.google.com/mail/?extsrc=mailto&url=%s with the code below and then clicking on a mailto: link and it works fine.
To replicate:
Please run this code, it will create the Outlook handler and set it to active.
//start - create handler
var handler = Cc["#mozilla.org/uriloader/web-handler-app;1"].createInstance(Ci.nsIWebHandlerApp);
handler.name = 'Outlook Live';
handler.uriTemplate = 'http://mail.live.com/secure/start?action=compose&to=%s';
//end - create handler
//start - add handler
var eps = Cc["#mozilla.org/uriloader/external-protocol-service;1"].getService(Ci.nsIExternalProtocolService);
var handlerInfo = eps.getProtocolHandlerInfo('mailto');
handlerInfo.possibleApplicationHandlers.appendElement(handler, false);
//end - add handler
//start - set as active handler
handlerInfo.preferredAction = Ci.nsIHandlerInfo.useHelperApp; //Ci.nsIHandlerInfo has keys: alwaysAsk:1, handleInternally:3, saveToDisk:0, useHelperApp:2, useSystemDefault:4
handlerInfo.preferredApplicationHandler = handler;
handlerInfo.alwaysAskBeforeHandling = false;
//end - set as active handler
var hs = Cc["#mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService);
hs.store(handlerInfo);
Click on a mailto link. For example I clicked on "Support E-mail" on my addon page here: https://addons.mozilla.org/en-US/firefox/addon/mailtowebmails/ the link is mailto:noitidart
It opens in Hotmail but the to is mailto::
Why does the mailto not work in step 3?
If you just paste into the url bar: http://mail.live.com/secure/start?action=compose&to=noitidart#gmail.com it loads up fine.
The web protocol handler will send the full .spec of the URI, meaning it will send mailto:abc#example.org and not just abc#example.org.
Apparently the http live.com endpoint doesn't handle that.
However, in a shocking twist, the https live.com endpoint does handle it, i.e. https://mail.live.com/secure/start?action=compose&to=mailto:abc#example.org will extract the right address from the mailto: URI.
So, update your web protocol template URI to the following and you should be fine (until MS messes up again):
https://mail.live.com/secure/start?action=compose&to=%s

How to fetch mail by id with barbushin imap class

I'm currently working on the imap class by barbushin. It's the only php class over the internet I can find regardless to any encoding issue. Thanks to the coder.
I have a list of messages in a table. Each message sending a message id as GET (say $mid). When a link clicked, the page turned into a view page. It should open that message and display the relevant content right? But it is not. Every message has the same content (the 1st content). The code is designed for gmail but I use it for my client. And it's work.
This is a code:
require_once('../ImapMailbox.php');
define('EMAIL', 'my#domain.com');
define('PASSWORD', '*********');
define('ATTACHMENTS_DIR', dirname(__FILE__) . '/attachments');
$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', EMAIL, PASSWORD, ATTACHMENTS_DIR, 'utf-8');
$mails = array();
// Get some mail
$mailsIds = $mailbox->searchMailBox('ALL');
if(!$mailsIds) {
die('Mailbox is empty');
}
$mailId = reset($mailsIds);
$mail = $mailbox->getMail($mailId);
var_dump($mail);
var_dump($mail->getAttachments());
The original is here: https://github.com/barbushin/php-imap
Finally, I found my way home. According to the script there's a line says "mailId". Which is straight forward what is it about.
It was set to the first array by reset(). So the only thing I need to do is extract the message id from it ($mailId is an array of ids). So I simply add an array behind it.
$mailId=$mailsIds[$_GET[uid]];
While $_GET[uid] is a message id sent from a previous page.

Grails Mail plugin - what is the proper way of using default content when sending empty mails?

I added to Config.groovy default mail body by adding this line:
grails.mail.default.body = "Test body"
and then I am passing adress, subject and body from form by params in a sendMail method:
sendMail {
to params.adress
subject params.title
body params.body
}
It works fine if params.body is not empty, but when user ignores this field the default body is not added to mail - the mail cant be sent without body.
Class
grails.plugin.mail.GrailsMailException
Message
message has no content, use text(), html() or body() methods to set content
What mistake I did here? Is there some special way I need to handle default content of mail body, subject or other fields?
The mail plugin has special support for default.to and default.from but not default.body (or subject, or anything else). You could handle it yourself:
sendMail {
to params.adress
subject params.title
body(params.body ?: grailsApplication.config.grails.mail.default.body)
}
but the plugin won't do it for you.

Resources