Sending email attachments via UWP EmailManager not working - email-attachments

Sending an attachment from a universal app with the following code is not working, why?
Dim emailMessage As New EmailMessage()
emailMessage.[To].Add(New EmailRecipient("a#b.com"))
emailMessage.Subject = "Test"
emailMessage.Body = "Hello World"
Dim localAppFolder = Windows.Storage.ApplicationData.Current.LocalFolder
Dim file = Await localAppFolder.CreateFileAsync("SomeFile.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting)
Await Windows.Storage.FileIO.WriteTextAsync(file, "aaaa")
Dim fileRef = RandomAccessStreamReference.CreateFromFile(file)
emailMessage.Attachments.Add(New EmailAttachment(file.Name, fileRef))
Await EmailManager.ShowComposeNewEmailAsync(emailMessage)
To, subject and body show fine in Outlook, but the attachment is missing: Outlook screenshot

I believe it is because the Outlook is a Desktop app. As I understood, the EmailManager.ShowComposeNewEmailAsync uses mailto: protocal to launch mail client app and use share to provide the email content.
If you choose the mail store app when the select default app dialog launches, you will be able to see the attachment as following:
If you have previously chosen Desktop Outlook app as the default as for mailto protocol, you have to change the default app for the mailto: protocol association in control panel .
Previously, the ShowComposeNewEmailAsync only works for windows phone runtime app. And it is not up-to-date in the document, because it doesn't include the win 10 support.
On Windows 10 mobile, it works well without any problem. But on Windows Desktop, you have to choose a store app.

This is still an issue in 2019, but I have found a workaround for my project.
I simply assemble an *.msg file with recipients, subject, body, attachments etc. and save it to the apps local cache folder. It can then be launched using Launcher.LaunchFileAsync
As *.msg files are associated with outlook, it will most likely be the default app to open this kind of file. You can create such a file using MsgKit
I have prepared a demo project at: https://github.com/Moolt/UniversialWindowsPlatform.LaunchOutlook

Related

How to interact with native apps using appium-flutter-driver & webdriverIO project

I'm using appium-flutter-driver & webdriverIO to automate the flutter mobile app.
I have a use case in my application where clicking on
Mail us button opens Gmail app with subject, body
Call us button opens Dailer app with phone number
I want assert/verify that gmail/phone app is opened. either one of following is fine
verifying that gmail/phone app package name
verifying the subject, content in gmail compose screen is also fine
I see here https://github.com/appium-userland/appium-flutter-driver that
await driver.switchContext('NATIVE_APP');
await (await driver.$('~fab')).click();
what is ~fab means here?
How to find elements using ID, text, class in this case and perform click, enterText, etc operations?
I'm not sure what ~fab means. But the available finders are mentioned here, with links to the documentation. The available commands are mentioned here, with links to the documentation.
An example of a finder by semantics label with a click:
element = FlutterElement(self.driver, FlutterFinder().by_semantics_label('Back'))
element.click()
An example of entering text:
driver.execute_script('flutter: enterText')
Got these examples from here.

Outlook Show Email Images to User

I'm trying to send mails to some users which are basically built over images. How can I get those images to download by default in the users' (outlook) mailbox?
I did try encoding the image in base64 and sending it, not as a hosted image but embedded in email-html. But that too, did not work :( (I was SO sure that it would)
The client (organization) is well aware of this (that we'll be exchanging mails). Is there any setting that can be tweaked in the admin panel of MSExchange or o365 which can allow this?
Users have to have that set in their preferences. You cannot make it automatically do it as an email sender due to SPAM senders and security reasons.
Outlook allows adding hidden attachments, you may refer mention they in the message body (embedded images). In the message body you may see the following tags:
<img src="cid:some-image-cid" alt="img" />
The "cid:" prefix means that name refers to the attached image with the specified content ID.
Attachment attachment = newMail.Attachments.Add(
#"E:\Pictures\image001.jpg",
OlAttachmentType.olEmbeddeditem, null, "Some image display name");
string imageCid = "image001.jpg#123";
attachment.PropertyAccessor.SetProperty(
"http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);
String.Format("<body><img src=\"cid:{0}\"></body>", imageCid);

How can we add attachment to default mail Application Using NSWorkSpace in cocoa Mac OSX application

I am using NSWorkspace to set TO, CC, BCC , SUBJECT and body text in default mail application through my application. How can i add attachments using NSWrokSpace?
Is there any way to attach files in the default mail app using NSWorkSpace?
I have tried using NSSharingService but problem with NSSharingService is that you cannot set CC and BCC email addresses in the default application Email Compose.
Is there any way to add CC, and BCC recipients using NSSharingSerivce ??
or is there any way to add attachments in mail using NSWorkSpace??
My code to open and set TO, CC and BCC is here
NSWorkspace.sharedWorkspace().openURL(NSURL.init(string:"mai‌​lto:(self.txtTo.‌​stringValue)"+"?subj‌​ect=YourSubject"+"&c‌​c="+self.txtCC.strin‌​gValue+"&bcc="+self.‌​txtBcc.stringValue)!‌​)
And Using NSSharingService i can set only recipients as TO
service!.recipients = [self.txtTo.stringValue]
service!.subject = "Subject"
thanks!.
It looks like NSSharingService has the method performWithItems, which takes an array of the things you want to share.
It appears you can create a sharing service of type NSSharingServiceNameComposeEmail and then attach a message body and a file to attach.
I've never used NSSharingService before, so the above is based on some Googling and reading the docs. (And I mostly work in iOS these days so my Mac OS is getting a little stale.)
Check out this link:
http://cutecoder.org/featured/programmatically-sending-rich-text-mail-attachment-mac/

Custom action button (Junk+)

Is it possible to create custom action button? ["Junk" button with more complex action]
I would like to:
mark the message as junk
copy the message to special folder common to all email accounts
move the message to per account junk folder
AFAIK Current junk button can deliver 1 and 3 without 2.
I need it for custom reporting to external services e.g. spamcop, knujon and other.
If thunderbird can not deliver such functionality then I am willing to accept suggestion of other Linux email clients capable to deliver such functionality.
Obviously this is easy to do with a custom XUL add-on and some basic Thunderbird chrome scripting.
This can also be done with the Custom Buttons Add-on for Thunderbird. Here is the code for the button, you will need to replace with your own folder URI's. The URI's for the folders can be accessed from the right-click content menu Properties .
/* Code */
// 1. mark the message as junk
goDoCommand("cmd_markAsJunk");
// 2. copy the message to special folder common to all email accounts
var copyUri = "imap://{user}#{host}/{path}/{folder}";
var copyFolder = GetMsgFolderFromUri(copyUri);
MsgCopyMessage(copyFolder);
// 3. move the message to per account junk folder
var moveUri = "mailbox://{user}#Local%20Folders/{spam folder}";
var moveFolder = GetMsgFolderFromUri(moveUri);
MsgMoveMessage(moveFolder);
The button script definitions are stored in the file:
{thunderbird profile}/custombuttons/buttonsoverlay.xul
You may be able to update this file automatically to ease deployment.
WARNING: Thunderbird 31 requires different code.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1043819

Is it possible to send an email to a specific recipient through Share Contract?

I'm trying to send an email from a Metro application (js or c#, doesn't matter) Is Share Contract the way to go? As far as I can tell you can't specify the email's recipient through the Share contract.
This is correct. The share contract is also available for other apps, i.e. Tweetro, which do not use an email address, therefore the user must type in an email address per hand. A mailto Uri does not work, it must be a valid Uri, otherwise it will not be displayed. See http://msdn.microsoft.com/en-US/library/windows/apps/hh465261 for all options you can set up for sharing via charms.
You are correct. There is no way. You could try constructing a mailto Uri and launching it
Use the EmailManager.ShowComposeNewEmailAsync API if you're on Windows 10. It uses the mailto: protocol underneath.
You can use a Uri scheme to open an app, but you need to use LaunchUriAsync. Also, with LauncherOptions set, if the user doesn't have the app installed Windows will bring them to the Store.
For example, here is my approach that only opens the mail app to side of the screen (I use it for error reporting), or if they have Outlook installed it will use it instead:
private async Task<bool> ReportErrorMessage(string detailedErrorMessage)
{
var uri = new Uri(string.Format("mailto:email.address#domain.com?subject=Error Report&body={0}", detailedErrorMessage), UriKind.Absolute);
var options = new Windows.System.LauncherOptions
{
DisplayApplicationPicker = true,
DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseLess,
PreferredApplicationPackageFamilyName = "microsoft.windowscommunicationsapps_8wekyb3d8bbwe",
PreferredApplicationDisplayName = "Mail"
};
return await Windows.System.Launcher.LaunchUriAsync(uri, options);
}
In the case of an email uri, the app is installed already, so it should work equally for every user. Additionally, if you know the FamilyPackageName you can set the preferred app to use.
Find more information about using the uri launcher here.