I am developing a Windows8 Metro App using c# xaml and I have to send the app link as an e-mail to someone using the share contract.
What I have tried is
private void RegisterForShare()
{
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.ShareLinkHandler);
}
private void ShareLinkHandler(DataTransferManager sender, DataRequestedEventArgs e) {
DataRequest request = e.Request;
request.Data.Properties.Title = "Sharing My Link";
request.Data.Properties.Description = "Add a link (URI) to share";
var _Uri = new Uri("https://login.live.com/");
Windows.System.Launcher.LaunchUriAsync(_Uri);
}
And also,
void App_QuerySubmitted(Windows.ApplicationModel.DataTransfer.DataTransferManager sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs args)
{
App.SettingsFlyout.Equals(args.Request, ApplicationExecutionState.Running);
}
But it works in a way where the specified link just opens and not a feature where the email of the link could be sent to soemone.
Any suggestions or solutions please?
While you can use the share charm to let the user sent text if you want to the user to definitely send email (as opposed to Twitter / Facebook) then you should use the mailto protocol.
await Launcher.LaunchUri(new Uri("mailto://test#address.com?subject=email"));
There's no built-in API for sending emails. Microsoft recommend to use share charm to send the email. Though if you want to send email via you need to go for commercial library called Mail.dll
Try this
var mailto = new Uri("mailto:?to=recipient#example.com&subject=Your subject&body=Your text");
await Windows.System.Launcher.LaunchUriAsync(mailto);
Related
I'm specific about Outlook here because there is a way to do this with the native Windows Mail app. The problem is that I need to do this with Outlook which isn't a native UWP Windows app.
I'm aware of the EmailManager API that exists for UWP. But, as it's stated in the docs, it's not possible to use it with a HTML body.
My current workaround for the native Mail app uses the DataTransfer UWP API. With it I can open the Windows 10 share dialog:
var dtm = DataTransferManager.GetForCurrentView();
dtm.DataRequested += WindowsShare_DataRequested;
DataTransferManager.ShowShareUI();
And in the data request event I put the HTML body into the request data like this:
var request = args.Request;
var deferral = request.GetDeferral();
try
{
var htmlBody = HtmlFormatHelper.CreateHtmlFormat(<HTML body here>);
request.Data.SetHtmlFormat(htmlBody);
}
catch (Exception ex)
{
...
}
finally
{
deferral.Complete();
var dtm = DataTransferManager.GetForCurrentView();
}
This works but the share dialog only shows native apps like Windows Mail.
I am trying to send email from my WP8 App using EmailComposeTask. But it is not sending the mail. Please correct the code if i am missing some statements.
My code is:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
EmailComposeTask email = new EmailComposeTask();
email.Body = "Test email from an app on click";
email.Subject = "Testing";
email.To = "amittal776#gmail.com";
email.Show();
}
On clicking Button , i want this mail to be send to amittal776#gmail.com. When i m running this app it asks for select an account from it will send mail after choosing it send the mail but reciever is not recieving the mail.
There is no error in the code. EmailComposeTask is working as it should. It will always ask you to choose email account.
See this link:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394003%28v=vs.105%29.aspx
Same happens when you use a MediaShareTask, it will ask if you want to share on facebook/twitter/email etc etc.
This is how they are programmed in Windows phone.
I am developing a WP8.1 app, when I try using ShareMediaTask to share a picture it shows me a list of apps where I will share the picture. Facebook, Twitter and other apps like Whatsapp are not included in the list; it shows me only share to OneNote. Taking note that I debug from device with Facebook and Twitter installed on it.
If someone could help me thankfully.
This is my simple code :
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = fileName;
shareMediaTask.Show();
Do I have to add something ?!
You'll want to take a look at Sharing content for Windows Runtime apps. Sharing is different between Silverlight and Runtime apps.
Here is a basic sample on how to share files:
When you are ready to share:
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager,
DataRequestedEventArgs>(this.ShareStorageItemsHandler);
And then populating the data:
private async void ShareStorageItemsHandler(DataTransferManager sender,
DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "Share StorageItems Example";
request.Data.Properties.Description = "Demonstrates how to share files.";
// Because we are making async calls in the DataRequested event handler,
// we need to get the deferral first.
DataRequestDeferral deferral = request.GetDeferral();
// Make sure we always call Complete on the deferral.
try
{
StorageFile logoFile =
await Package.Current.InstalledLocation.GetFileAsync("Assets\\Logo.png");
List<IStorageItem> storageItems = new List<IStorageItem>();
storageItems.Add(logoFile);
request.Data.SetStorageItems(storageItems);
}
finally
{
deferral.Complete();
}
}
Only apps that implement sharing will show up in the list. Currently Twitter and Facebook have not released an app that implements sharing.
For more information of receiving shared content, see this doc.
I have a c# app and I wish to send an sms to a specfic User whenever I have an update for that User.
I intend to have many different Users.
I heard that it is possible to send SMS via Skype.
I download some sample code but when I run it I got an error saying 'connection refused'.
I also then came across a blog stating that using Skype this way has potential errors like the SMS not getting through or taking days to get through.
I heard also that Skype are not that good with support in this area.
But, I cannot get past this error to find that all out.
If I send the sms directly using Skype's GUI/App then it comes through no problem.
So, is my code correct?
Should I use Skype for this at all?
Has anyone had a similar thing to do and has a better idea?
Thanks.
CODE:
private void button1_Click(object sender, EventArgs e)
{
var sendNumber = "+44-79-7059-0893";
var msgBody = "test message";
SendSMSMessage(sendNumber, msgBody);
}
void SendSMSMessage(string number, string body)
{
try
{
var skype = new SKYPE4COMLib.Skype();
skype.Timeout = 120 * 1000;
var smsType = SKYPE4COMLib.TSmsMessageType.smsMessageTypeOutgoing; //error occurs here
var message = skype.CreateSms(smsType, number);
message.Body = body;
message.Send();
}
catch (Exception ex)
{
}
}
Just in case anyone is following this I got this response from Sjype:
Andrew,
I am guessing your talking about the Desktop API (formally Public API) which was deprecated in December 2013? I would strongly encourage you not to build on this API as anything you build will have a limited shelf life.
Kind regards
Allen Smith
Program Manager
Skype Developer
I'm using the new version of tweetsharp api (v2) and i've had some problems with implementation on wp7...
i'm developping one app that use this api for tweet phrases to user account who's use my application...
so to configure the twiter user account i save the login and password to... when user wants to tweet i get access to his account and tweet that phrase...
My problem is how to make the login to twitter account... i try this but it's not woking....
private void button1_Click(object sender, RoutedEventArgs e)
{
var service = new TwitterService(consumerKey, consumerSecret);
Action<OAuthAccessToken, TwitterResponse> act = new Action<OAuthAccessToken, TwitterResponse>((a, b) => Result(a, b));
try
{
service.GetAccessTokenWithXAuth(username,password,act);
}
catch (Exception) {
}
}
private void Result(OAuthAccessToken a, TwitterResponse b)
{
}
I've read the Api v2 documentation but it's diferent than my method because some methods are new and different than the documentation reports....
thanks very much for help...
stab- have twitter ok'd you for xAuth? Apparently, it's only permissible if your app/apiKeys have been whitelisted for it.
Read this: https://dev.twitter.com/docs/oauth/xauth
Your other apps for iPhone may have used regular OAuth and not xAuth. Like dethSwatch said, Apps have to be approved by Twitter in order to use xAuth.
Only caveat with xAuth is you do not get access tokens to direct messages.