I am creating a sample Win8 app and using share contract I am trying to share HTML Content. When the user select email app from the share application option I want to set email address in TO field. How can I do so? Following is my code written to share HTML content:
Code:
DataPackage requestData = request.Data;
requestData.Properties.Title = this.PageViewModel.JobInformationDetail.JobNumber;
requestData.Properties.Description = this.PageViewModel.JobInformationDetail.CustomerSignatureName;
//requestData.SetText("Sample Text");
StorageFile signatureStream = await GetInkManagerStream();
requestData.SetHtmlFormat(Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.CreateHtmlFormat(this.GetMailDescription()));
Following images shows where to set the email address in To field:
You can't do that. We'll have a solution to this until WinRT come up with a standard email DataPackage format to StandardDataFormats and support it in the email app.
I think Microsoft's default Mail should be upgraded. It's entirely depend upon sharing target app to show particular data to particular place. DataPackage's Title property is set as subject and Description property is set as mail body but there's no provsion for to email(s).
If sharing experience is best one then user will user default Mail app otherwise they will go for another mail apps.
Related
I want to send two buttons in email. On clicking of that buttons user should be able to Approve or Reject approval. It should work on gmail as well as outlook. I am not sure if web api will work. I am using c# for sending email. Please share any idea.
Email clients (Outlook as well) don't allow executing any JavaScript code in the message body for security reasons. The best what you could do for all mail clients is to paste a hyperlink in the message body and count responses on the server side when users click it.
As for for Outlook, you can use the MailItem.VotingOptions property which allows setting a string specifying a delimited string containing the voting options for the mail message.
Voting options on messages are used to give message recipients a list of choices and to track their responses. To create voting options programmatically, set a string that is a semicolon-delimited list of values for the VotingOptions property of a MailItem object. The values for the VotingOptions property will appear under the Vote command in the Respond group in the ribbon of the received message.
using Outlook = Microsoft.Office.Interop.Outlook;
private void OrderPizza()
{
Outlook.MailItem mail = (Outlook.MailItem)Application.CreateItem(
Outlook.OlItemType.olMailItem);
mail.VotingOptions = “Cheese; Mushroom; Sausage; Combo; Veg Combo;”
mail.Subject = “Pizza Order”;
mail.Display(false);
}
I have a Blazor server app and I use Mailkit to send emails. Using a model I bind and send the email to the given address.
I have the following code that i use to send emails:
email.To.Add(MailboxAddress.Parse(model.ToEmail));
email.Subject = "EEXI Calculation Results";
email.Body = new TextPart(TextFormat.Html) { Text = "Full Name" };
Similarly how I bind the email address using:
email.To.Add(MailboxAddress.Parse(model.ToEmail));
I would like to bind other values from the inputs and show both text
email.Body = new TextPart(TextFormat.Html) { Text = "Full Name:",model.name};
That's what email templates are used for, there are many ways to create and use them. Here are some useful links:
Custom (simple) string template:
Create email templates in code... it's very basic, but sometimes that's all you need.
public string NewUserEmailTemplate(User user, string confirmationUrl){
return $"Welcome {user.FirstName} {user.LastName}! You are now a registered user. Please click the following url to confirm your account: {confirmationUrl}";
}
Razor page .cshtml email template
The more advanced and better way of doing email templates. Here's a link to a tutorial:
https://scottsauber.com/2018/07/07/walkthrough-creating-an-html-email-template-with-razor-and-razor-class-libraries-and-rendering-it-from-a-net-standard-class-library/
I am currently using the outlook mail api to retreive messages from a specific shared folder (List Messages Request), when i get a response from the query i want to read the body content in this case my header prefers html.
What i'm trying to achieve is string replacement from the html response.
The problem is inside my shared emails i have something like this:
Hello [UserName], further text in mail message, Regards [CompanyName].
and the response i get from the api looks like this:
<p class=\"MsoNormal\">Hello [<span class=\"SpellE\">UserName</span>],</p><p class=\"MsoNormal\"> </p><p class=\"MsoNormal\">further text in mail message, Regards [CompanyName].</p>
the response shows a spelling error has been returned with one of my string placement texts and not the other, this is not ideal because i dont want to rely on me writing some code to check if:
[<span class=\"SpellE\">UserName</span>]
exists or not, mainly because this could be subject to change at any given time and that would be a breaking change to the system.
Is there any way i can disable spell checking being returned in the html?
Try disabling spell checking in Microsoft Outlook,
File -> Options -> Mail -> Spell
either through the application or programatically by altering the configuration in the windows registry.
Look at
HKCU\Software\Microsoft\Office\11.0\Outlook\Options\Spelling
HKCU\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Office\OutlookSpellingOptions
HKCU\Software\Microsoft\Spelling
In an ASP.NET MVC5 C# application I am using the standard code for sending confirmation emails when a user registers, something I've done in multiple projects:
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking here");
Normally when the recipient receives the email, it's content-type is text/html. However, in this one application, the emails arrive with content-type text/plain and the content is not rendered as html, it is rendered as plain text. It should like this:
Please confirm your account by clicking here
But it looks like this:
Please confirm your account by clicking here
I searched the docs but cannot find any information that indicates why this would be or indeed how to change this behavior.
I also updated to the latest version of the Microsoft ASP.NET Identity Core (2.2.1) thinking that might help, but it didn't have any effect on the issue.
I also tested sending from a Google Apps email account for a different organization (which I use for other apps with this exact same code to send this confirmation email and know it sends as html) in case there are some settings in there that matter.
Any ideas on why it sends as text/plain and how I can fix this?
Thanks!
The problem more than likely isn't with your Identity, it is probably just with the mail function itself. Have you set the MailMessage.IsBodyHtml property to true?
MailMessage message = new MailMessage(fromEmail, toEmail, subject, body);
message.IsBodyHtml = true; // here
This will set the body of the email to be rendered as HTML. By default, the property is false, so you need to explicitly declare it to be true.
The issue is likely with the mail service/api you're using. I have used several and they generally have either an optional htmlBody parameter or an isBodyHtml parameter. If you specify which one you're using, or provide the code for the SendAsync Methos in the EmailService class (in IdentityConfig.cs), it'll probably be easy to point you in the right direction.
If your stuck with plain text, you can send plain text with a url and the client will often convert it into a link for the user. Outlook and gmail do this.
So, it would look like this instead:
await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account:" + callbackUrl);
You can use SendGrid API to send HTML type emails and they also provide transactional templates.
Links
https://sendgrid.com/
Even advised in the Asp.net core doc
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/accconfirm?view=aspnetcore-2.2&tabs=visual-studio
My team and I have a very specific and frustrating issue. We have an MVC4 web application that many people utilized within a company (no external exposure). Some of our processes generate emails to other employees with links back to the application.
For example, there may be some activity that one employee sees and wants to attend. They can can an email to the other employee saying they would like to attend.
In these emails, we put an anchor tag in with the link back to our application and some query string stuff to help direct it to the right page.
All of that works wonderfully. Now, the problem is, we want the link (from the email) to load in an existing window with the application, if it exists. Normally, I believe, this would be done with setting the target attribute in the anchor tag, but that doesn't work, it just opens in a new tab.
This is what the anchor tag source from the email looks like (i've changed some text so that it hides company related info):
Please <a target="appMain" href='http://domain/app/controller.aspx/view?
keyname=querystringparam1¶ms={"prop1":val,"prop2":va;}'>
click here</a> to approve and go to app
this is our smtp function to send the mail:
public void SendMail(EmailContent emailContent, string mailConfigurationPath)
{
var toRecipients = string.Join(",", emailContent.ToList);
var mailMessage = new MailMessage(emailContent.From, toRecipients)
{
IsBodyHtml = emailContent.IsBodyHtml,
Body = emailContent.Body,
Subject = emailContent.Subject
};
var smtpClient = new SmtpClient
{
DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory,
PickupDirectoryLocation = mailConfigurationPath
};
smtpClient.Send(mailMessage);
}
Is what I'm trying to achieve even possible? It seems pretty straight forward, maybe I'm just going about it the wrong way. Would love some help or even some "crazy" ideas.
This is not possible, because it creates a vulnerability in the email program itself...
http://thenextweb.com/insider/2013/01/07/yahoo-mail-users-hit-by-widespread-hacking-xss-exploit-seemingly-to-blame/
Also, it goes against all the normal user interface guidelines for email programs. Users don't expect an email to transform into an app. They are very familiar with clicking on links in emails though, so you wouldn't want that action to do something weird.