I am using the following code in my Xamarin.Forms project to open the native email client on the device with some information prepopulated in the body, but the email client on Android opens without a set body and subject; it only has the mailto property.
The following code works for iOS, but on Android, it opens the email clientand only displays mailto.
string body = "Name : "+"\r\n" +NameLabel.Text +"Phone : "+Phonelabel.Text +"\r\n"+ "Email : "+ EmailLabel.Text ;
string strMailTo = #"mailto:test#gmail.com?Subject="profile"&Body="+body;
Device.OpenUri(new Uri(strMailTo));
I think you can try this plugin. I have used for some apps and works fine. It's PCL.
https://www.nuget.org/packages/Xam.Plugins.Messaging/
I have code that uses Device.OpenUri from Xamarin Forms. I think perhaps your quotes are confusing it:
Device.OpenUri(new Uri("mailto:email#test.com?subject=MobileTing&body=A message for you consideration."));
I used in Xamarin.Forms DependencyService and this code:
var email = new Intent (Android.Content.Intent.ActionSend);
email.PutExtra (Android.Content.Intent.ExtraEmail,
new string[]{"person1#xamarin.com", "person2#xamrin.com"} );
email.PutExtra (Android.Content.Intent.ExtraCc,
new string[]{"person3#xamarin.com"} );
email.PutExtra (Android.Content.Intent.ExtraSubject, "Hello Email");
email.PutExtra (Android.Content.Intent.ExtraText,
"Hello from Xamarin.Android");
it full example
Related
I am using the code snippet below from here and am getting '+' signs instead of spaces in my Outlook email app. All other text is correct. I do not think I am doing anything fancy with the strings, but I am using string interpolation.
public async Task SendEmail(string subject, string body, List<string> recipients)
{
try
{
var message = new EmailMessage
{
Subject = #"{StoreName} Needs a Payer",
Body = #"It needs a separate payer...",
To = recipients,
//Cc = ccRecipients,
//Bcc = bccRecipients
};
await Email.ComposeAsync(message);
}
catch (FeatureNotSupportedException fbsEx)
{
// Email is not supported on this device
}
catch (Exception ex)
{
// Some other exception occurred
}
}
This is a .NET Xamarin iOS app. What can I do to make sure spaces are used and not '+' signs?
I tried changing the BodyFormat property and got the following results: Setting the BodyFormat to Text does not change the behavior. Still get + signs instead of spaces, but if I use a iOS Mail application, the spaces are fine. If I set it to BodyFormat HTML, the Outlook application just crashes, but the iOS Mail application is fine.
The solution was to update to the latest version of Xamarin.Essentials.
This is an Outlook issue in the iOS app only.
To fix it, use %20 instead of space, and it will work fine with all mail clients.
We can use the Uri.EscapeDataString method to encode the string and then we can pass it in the body and subject.
i need to get record from keychain via: SecureStorage.GetAsync("xxx");
In Xamarin.iOS app i have this:
var s = new SecRecord(SecKind.GenericPassword)
{
Label = "Item Label",
Description = "Item description",
Account = "Account",
Service = "Service",
Comment = "Your comment here",
ValueData = NSData.FromString("Something"),
Generic = NSData.FromString("foo")
};
var err = SecKeyChain.Add(s);
I tried make native iOS app and i can get from Keychain value of "Account", but no in Xamarin.Forms. Where Xamarin.forms store encrypted data please? Is possible to get(share) some values from iOS in Forms? For example FCM token from Firebase?
Iam new in Xamarin
Thank you for response
Where Xamarin.forms store encrypted data
Essentials SecureStorage on iOS uses a SecRecord for storage under an Account name (alias) that is constructed via:
// Special Alias that is only used for Secure Storage. All others should use: Preferences.GetPrivatePreferencesSharedName
internal static readonly string Alias = $"{AppInfo.PackageName}.xamarinessentials";
re: https://github.com/xamarin/Essentials/tree/develop/Xamarin.Essentials/SecureStorage
I need to make authentication using Google for my app (Xamarin Android Native). I used this article. I passed step by step. Also I created client id in Google Developer Console. But I have an error. The package name is displayed on the screenshot. What can be wrong with this?
public const string RedirectUrl = "com.xplorpal.pal_:/oauth2redirect";
_auth = new OAuth2Authenticator(clientId, string.Empty, scope,
new Uri(AuthorizeUrl),
new Uri(redirectUrl),
new Uri(AccessTokenUrl),
null, IsUsingNativeUI);
I think the problem is the underscore in the redirect URL:
public const string RedirectUrl = "com.xplorpal.pal:/oauth2redirect";
_auth = new OAuth2Authenticator(clientId, string.Empty, scope,
new Uri(AuthorizeUrl),
new Uri(redirectUrl),
new Uri(AccessTokenUrl),
null, IsUsingNativeUI);
Here you can find more info about why the UriFormatException is thrown. https://msdn.microsoft.com/it-it/library/z6c2z492(v=vs.110).aspx
I am creating a Cortana skill on the Cortana canvas, I have a button.
I wanted to know if it possible to have an 'imback' type of button to open a webpage.
Ye, for example
var message = context.MakeMessage() as IMessageActivity;
message.ChannelData = JObject.FromObject(new
{
action = new { type = "LaunchUri", uri = "skype:echo123?call" }
});
await context.PostAsync(message);
this code will start a call with echo123 user on skype
Reference: https://learn.microsoft.com/en-us/cortana/tutorials/bot-skills/bot-entity-channel-data
You can supply an openUrl to a card action, or even use ChannelData to send a LaunchUri command, deep linking to an application. (I haven't tried this, but I assume 'http://websitename.com' will launch in the Cortana host platform's default browser.)
activity.ChannelData = new {
action = new { type = "LaunchUri", uri = "http://websitename.com"}
};
I'm using Umbraco 4.6.2, and need to extend the default notifications it provides. For the sake of this question, let's say I am trying to add an "Unpublish" notification.
In \umbraco\presentation\umbraco\dialogs\notifications.aspx.cs it constructs the list of checkbx items shown to the user when opening the "Notifications" dialogue from the context menu.
I see that each Action has a ShowInNotifier property - how can I set this value to true for the UnPublish action?
Does this require modifying the core codebase, or is there a nice way I can gracefully extend Umbraco?
So after I have added this, users can subscribe to the UnPublish notification (am I missing any steps here?).
Will this automagically send notifications now?
I'm guessing not, so the next thing I have done is hooked the UnPublish event:
public class CustomEvents : ApplicationBase
{
public CustomEvents()
{
Document.AfterUnPublish += new Document.UnPublishEventHandler(Document_AfterUnPublish);
}
void Document_AfterUnPublish(Document sender, umbraco.cms.businesslogic.UnPublishEventArgs e)
{
var user = User.GetCurrent();
if (!string.IsNullOrEmpty(user.Email) && user.GetNotifications(sender.Path).Contains("UnPublish"))
{
//Send a notification here using default Umbraco settings, or, construct email and send manually:
string umbracoNotificationSenderAddress = ""; //How to get the address stored in umbracoSettings.config -> <notifications> -> <email>
//How to use the same subject/message formats used for other notifications? With the links back to the content?
string subject = "Notification of UnPublish performed on " + MyUtilities.GetFriendlyName(sender.Id);
string message = MyUtilities.GetFriendlyName(sender.Id) + " has just been unpublished.";
umbraco.library.SendMail(umbracoNotificationSenderAddress, user.Email, subject, message, true);
}
}
}
So the bits of that code that are not real/I need some pointers on:
Is that the correct way for checking if a user is subscribed to a particular notification?
How can I send a notification using the default umbraco settings? (e.g. generate an email just like the other notifications)
If that is not possible and I must construct my own email:
How do I get the from email address stored in umbracoSettings.config that
How can I copy the formatting used by the default Umbraco notifications? Should I manually copy it or is there a nicer way to do this (programmatically).
Any help (or even just links to relevant examples) are appreciated :>
My colleague got this working.
Create a class that overrides the action you wish to have notifications for.
You can see all the actions in /umbraco/cms/Actions
public class ActionUnPublishOverride : umbraco.BusinessLogic.Actions.ActionUnPublish, IAction
{
... see what the other actions look like to find out what to put in here!
In the overridden class, you will have a public char Letter. Set this to match the event to hook into. You can find the letters each event has in the database.
Set the public bool ShowInNotifier to true.
That's it!
I've got this working on Umbraco 4.7 by using the UmbracoSettings class:
http://www.java2s.com/Open-Source/CSharp/Content-Management-Systems-CMS/umbraco/umbraco/businesslogic/UmbracoSettings.cs.htm
umbraco.library.SendMail(umbraco.UmbracoSettings.NotificationEmailSender, newMember.Email, "email subject", "email body", false);