Send Email with pdf file as attachment in rhomobile - ruby

I want to send email using mailto tag with a single pdf file as attachment.
mailto tag opens the mail window with passed arguments like to and subject using:
Mail to Manager
But, attachments as a parameter isnt working.
Please suggest how to send pdf attachment in rhomobile.
Thanks

I think that you need to add the physical path to the PDF file for it to work (otherwise it may not know where the file is). This post on a forum says as follows:
The only problem is that this "mailto" command executes on the
client machine, therefore it tries to locate the attachment file by
a physical path, and not by a virtual path.
That is,
Using mailto:iudith.m#zim.co.il?subject=my report&body=see attachment&attachment="\myhost\myfolder\myfile.lis"
works ok, but only for local users (those connected to the same
network as the "myhost" machine).
Using mailto:iudith.m#zim.co.il?subject=my report&body=see attachment&attachment="http://myhost:myport/my_location_virtual_path/myfile.lis"
does not work, it does not recognize such a syntax as valid for
the attachment file.
In your case you would properbly need to look at this part of the Rhomobile docs (on file system access) to get the right path to your file.
EDIT:
From you comment I can see that you are trying to make it work on iOS (due to the iOS specific path).
In this discussion (from Rhomobile's Google Group) it is explained that mailto doesn't support attachments on iOS. It says as follows:
Don't know about other platforms, but you cannot do this on iOS. mailto: does not support attachments on iOS.
You can do it using a native API, MFMailComposeViewController.
This is a complete controller with UI, so you would have to write a Native View Extension to use it:
http://docs.rhomobile.com/rhodes/extensions#native-view-extensions
EDIT 2:
I've looked around and it seems that mailto doesn't support attachments on Android either. This is because Android supports the RFC 2368 mailto protocol, which doesn't include attachments. Here is a reference to the Android mailto url parser.
I would suggest that you do as suggested for iOS, write a native extension. I think this post would be relevant for you.

Related

How to access to Outlook (desktop client on macOS) stored emails programmatically

I'm trying to read emails from Outlook (desktop client on macOS) installation programmatically.
For Thunderbird I only need to read the files stored in /Users/xxxx/Library/Thunderbird/Profiles/xxxx.default-release/ImapMail/someemailaccount/.
Each file on that directory is named after the name of each folder on the email account (INBOX, Sent, etc.) and it contains all the emails (header, body and attachments). So all I have to do is to read that file with some programming language and apply the right decoder depending on the Content-Transfer-Encoding header.
For Outlook I found this file: /Users/xxxx/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/HxStore.hxd but it looks doesn't look to be readable, is it on a binary format? it is compressed or encrypted?
I tried to see its contents using Hex Field app and it displays that the file contains some blocks of data but those blocks look to be broken or encrypted/compressed (more info about that file here https://boncaldoforensics.wordpress.com/2018/12/09/microsoft-hxstore-hxd-email-research/):
<html><head>
<meta http-equiv="Content-Type" cp="text/;ñ; charset=utf-8"></Lð<body><div dir="ltr">1234567890ñ>
...
As you can see above, the contents look to be there but there are some strange characters on it. Also, the file has a lot of sections with no characters or random ones.
Does anybody know how can I read this file?
If you use the older outlook interface (or switch back to it) you can access the underlying sqlite database pretty easily.
However this will be discontinued at some point and Outlook will completely switch to the new interface based on Core Spotlight.
I am also looking for a way to access emails from the new interface, and yes the data seems to be in this file. Anybody else have pointers on how to access?

Is it possible to embed an Outlook .msg into an application using OLE?

If you have some application with an ordinary HWND, is it possible to embed an Outlook email .msg file into the window using OLE?
It appears that, after opening an Outlook message using OpenSharedItem, you can successfully QueryInterface for IOleObject. But after that, I can't seem to successfully call any IOleObject methods.
Thanks for any input.
MSG file format is well-described in MSDN. So, you can read the content without any third-party components or interfaces. To display the content (I guess the message body) you can use any web browser (for example, WebView2). The message body (HTMLBody) is represented by a regular web page. Most probably you will also need attached files that are used in the body.
Another possible alternative to use Extended MAPI for getting item properties. For example, you can use any third-party components for simplifying the work - Redemption.

Slack API slash command stripping out hyperlinks

I have created a slash command in Slack and am successfully receiving the relevant payload from that slash command. However, when the user creates a message that contains an embedded hyperlink, that link is being stripped out of the message and isn't included in the message payload.
For example:
This message contains a link
...gets converted to:
This message contains a link
Oddly, the link is successfully passed through as part of the payload if the user types a naked URL in their message, but it does not work if they create a link using the 'link' button in the Slack UI.
As per the docs, I have enabled the option "Escape channels, users, and links sent to your app" but this doesn't seem to fix the problem.
Can anyone help? How can ensure embedded hyperlinks aren't stripped out of the message payload?
Slack unfortunately haven't spent much time on slash commands since launch, and one of the things they don't support are links, as they were only added recently to the client's rich text editor.
Previously there was no way to create a link to a non-slack resource without pasting the full URL, so the slash command isn't sent it.
Your best option, if you are trying to do something with a link, would be to respond ephemerally to the user stating this and asking them to send the full URL via the slash command instead.

Google Drive API v3 : there isn't any way to get a download url for a google document?

The Google Drive API v2 to v3 migration guide says:
The exportLinks field has been removed from files. To export Google Documents, use the files.export method instead.
I don't want to export (download) the file right away. "files.export" will actually download the file. I want a link to download the file, later. This was possible in v2 by means of the exportLinks.
How can I in v3 accomplish the same? If it is not possible, why was this useful feature removed?
Besides, (similar problem to above) downloadUrl was also removed, and the suggested alternative ("files.get with ?alt=media") downloads the file instead of providing a download link. This means there is no way in v3 to get a public short lived URL for a file?
EDIT:
there is no way in v3 to get a public short lived URL for a file?
For regular files, apparently yes.
This seems to work fine (a public short lived link to the file with its right name and contents):
https://www.googleapis.com/drive/v3/files/ID?alt=media&access_token=TOKEN
For google apps files, no (not even private, as v2 exportLinks used to be).
https://www.googleapis.com/drive/v3/files/ID/exportmimeType=TYPEv&access_token=TOKEN
Similar to regular files, this URL is a short lived link to the file contents, but lacking of its right name.
BTW, I see the API is not behaving consistently: /drive/v3/files/FILEID delivers the right file name, but /drive/v3/files/FILEID/export does not.
I think the API itself should be setting the right Content-Disposition, as it is apparently doing when issuing a /drive/v3/files/FILEID call.
This file naming problem invalidates the workaround to the lack of ExportLinks in v3.
The v2 ExportLinks allowed me to link a file (which is not the same as getting its content right away). Anyone logged in and with the proper permissions was able to access it, and the link didn't needed any access_token, and it wasn't short lived. It was good and useful.
Building a link with a raw API call like /drive/v3/files/FILEID/export (with mandatory access_token) would be an close enough workaround (it is temporary and public, not the same as it was, anyway). However, the naming problem invalidates it.
In v2, regular files have a WebContentLink and google apps files have exportLinks. In v3 exportLinks are gone, and I don't see any suitable alternative to them.
Once you query for your file by id you can use the function getWebContentLink() to get the download link of the file (eg. $file->getWebContentLink() ).
I think you're placing too much emphasis on the word "method".
There is still a link to export a file, it's https://www.googleapis.com/drive/v3/files/fileIdxxxxx/export&mimeType=xxxxx/xxxxx. Make sure you URL encode the mime type.
Eg
https://www.googleapis.com/drive/v3/files/1fGBQ81haNU_nEiC5GITZD3bxT0ppL2LHg-C0ubD4Q_s/export?mimeType=text/csv&access_token=ya29.Gmo0BMvO-pVEPKsiD9j4D-NZVGE91MChRvwOcBSg3cTHt5uAClf-jFxcovQScbO2QQhwHS95eSGW1eQQcK5G1UQ6oI4BFEJJkntEBkgriZ14GbHuvpDL7LT2pKA--WiPuNoDDIuZMm5lWtlr
These links form part of the API, so the expectation is that you've written a client that sends authenticated requests, and deals with the response data. This explains why, if you simply paste the link into a browser without an access_token, it will fail. It also explains why the filename is export, ie. it isn't intended that your client would ever use a filename, but rather it should receive the data as a stream. This SO answer discusses the situation in more detail How to set name of file downloaded from browser?

how can I add company logo in email in cakephp?

I have created page for mail template and set buttons for preview template also.
I have set image path from my local machine like,
src="/projectname/app/webroot/img/logo.JPG"
and when i preview that template it displays logo.
when using that template when i send mail image is not displayed in email.
So can anyone please tell me what could be the issuee or i am missing something like mime types?
Thanks,
This won't work. The email is opened in a client, what the hack would a path like "/projectname/app/webroot/img/logo.JPG" mean to that client? What is the domain?
You can either add a domain to the SRC like src="http://example.com/projectname/app/webroot/img/logo.JPG". But this won't be displayed by default, because it is a security risk.
Imagine spammers including images like src="http://example.com/feedback?id=12345" to each email, where ID is identifying each e-mail address the mail is sent to. Each client downloading this image will acknowledge the receiving of this e-mail, letting the spammers know you are reading their spam. Most e-mail clients explicitly ask you whether images referred to in the mail should be downloaded or not.
An alternative solution is to include each e-mail as an attachment to the e-mail, then you can refer to it as an "inline" image. This does no requires external connection and is less of a security risk, mostly allowed by default in clients.
I've google up a component that supposedly supports also inlining, but you might find others as well:
http://bakery.cakephp.org/articles/CraZyLeGs/2006/12/18/swiftmailer-component-tutorial
Within emails, you must use your full path, not a relative path. To do this easily in CakePHP, use the: FULL_BASE_URL constant with the HTML Helper like this:
<?php
echo $this->Html->image(
FULL_BASE_URL . $photo['Photo']['path'].$photo['Photo']['filename']
);
?>
(obviously this could be done in one line, but I broke it down for ease of reading on StackOverflow)
That's probably because when you test on your local machine, that path is fine. But if you send an email to yourself (say gmail) your browser will probably look for the image somewhere like http://mail.google.com/gmail/projectname/app/webroot/img/logo.JPG and will not find your image there.
So you'll need to set your image source to something like http://localhost/projectname/app/webroot/img/logo.JPG.
The email client needs the absolute path to the image; use the HTML helper to attach the full base:
<?= $this->Html->image("logo.JPG", array('fullBase' => true)) ?>
Note that the /projectname/app/webroot/img/ is not required when using the HTML helper.
If you are using CakePHP v1.2 or 1.3 (yes they are deprecated - but hey someone might find this useful) you will need to add a Content-ID header to the image to be attached to the email so you can refer to it via the cid when using it inline in the message. Open the email controller of the cake installation and add this line in the __attachFiles() method:
$this->__message[] = 'Content-ID: <' . basename($file) . '>';
You can then add the image in your template like so:
The attachfile method of email class in v1.2 & 1.3 only accepts paths and does not have the added functionalities of later version hence the "hack"

Resources