Button in Email click to create new email with content - c#

Introdution
I am currently working a system develop with C#.
The system is about request approval.
When a request made, system will send email to user ask for response.
User's response will as simple as approve, reject or request update.
Question/Problem
Is it possible to have a button (approve or reject) in email content which allow user to response to system with only one click but without open browser?
Or, Is it possible to create button in email content which enable user to click to create new email with pre-set subject and recipient like following:
subject: request id - 123 - action - approve
to: response#system.com
as response email for user to send.
Then system can then recognize the email received and perform required back-end process.
Research Done
Research 1
What I currently found was outlook appointment email.
it done like second solution create new email with content for user send a response.
But, it only have options accept, decline and tentative.
And, I am not sure is blackberry support it like outlook.
The following is the blog found to create appointment email:
http://chuckdotnet.blogspot.my/2007/10/send-outlook-meeting-requests-with.html
Research 2
The following website teach you how to create hyperlink in email content which can create new email with pre-populate subject, body, and recipient
https://community.articulate.com/discussions/building-better-courses/hyperlink-to-create-an-already-written-email
However, No test had perform in blackberry yet.
Appreciate for any suggestion from you guys and I willing to try.

Is it possible to sent an email with button which can click to create
email with some pre-set content?
Yes, this is possible, see the System.Net.Mail code in the .NET framework.
https://msdn.microsoft.com/en-us/library/system.net.mail(v=vs.110).aspx
You can also see this StackOverflow question about how this is used.
Send e-mail via SMTP using C#
MailMessage mail = new MailMessage("you#yourcompany.com", "user#hotmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.google.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
Finally, your code should fire a serverside post on button click to have the server take care of sending the email. If data needs to be posted to the server, you may want to consider putting this data in a form input, which will post to your controller. You can then take that data and build the email with the example I provided in the links.

Related

Sending buttons in email in c#

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);
}

Why isnt the mail I sent through SendGrid visible in my sent items? (.net core)

I tried sending mails with the help of send grid mail service using .Net core.
var client = new SendGridClient(xxxxxxxxxxxxxxxxxxxxxx);
var from = new EmailAddress("test#abc.com", "Not User");
var subject = "TestMail";
var to = new EmailAddress("test#abc.com, "Example User");
var plainTextContent = "This is body";
var htmlContent = "";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
client.SendEmailAsync(msg).Wait();
The mails sent using this code are not visible in sent items of my mail box. What is the possible solution to this? Thanks in advance.
When you send the email it uses SMTP directly to sendgrid. When you send via Google they will automatically add it to your outbox. To do the same when someone else sends the message you would have to manually place a copy of the sent message in your outbox using IMAP.
What is the possible solution to this?
You could use SendGrid's BCC option will allow you to BCC an email address, in this case your mail account, with every email sent.
Go to your SendGrid Account>Manage>Settings>Mail Settings and turn on the BCC option.
Note: With this setting turned on, you will be charged an extra email for every email you send. So reclick on Manage and you will see the popup message.
Here is Send mailbox snapshot:

SmtpClient and MailMessage - How to format for anchor tags?

I have an application that requires a user confirm their email upon registering, so I've created some functionality to send the user an email, with a link, where they can click on the link and then confirm their email.
In order to do this I'm using both MailMessage and SmtpClient classes to send the email.
Currently, my code is thus:
public ActionResult Send() {
MailMessage email = new MailMessage {
Subject = "Confirm Email",
Body = "<a href='http://www.google.com'>Google</a>",
IsBodyHtml = true
};
SmtpClient smtp = new SmtpClient();
smtp.Send(email);
return RedirectToAction("Index", "Email");
}
Now upon researching I found that the IsBodyHtml flag will help if I'm trying to send an email that has HTML contained within, although upon testing, the emails I'm receiving are not formatting anchor tags properly.
Any idea what I may be doing wrong, or how differently I can go about formatting my message body?
Thanks!
So, I made a goof here. Seems that the messages I was trying to send myself were going to Outlook's Junk Mail folder, which strips out the href value and displays it in the e-mail.
If I right click on the email and select Display HTML then the link displays as expected.
Oops!

Restricting replyTo Field in SMTP (C#)

Is it possible to restrict the user to reply to a mail sent via SMTP server?
I have tried using obsolete before the method name but still reply mail could not be blocked
void sendmail()
{
string to = "abc#xyz.com";
string from = "def#abc.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = #"Test"
SmtpClient client = new SmtpClient(server);
client.UseDefaultCredentials = true;
}
above is the sample code.
As others have said in the comments, it is impractical/impossible (depending on level of access to their computers) to prevent a user replying to an email. However, you can prevent an exchange email account from receiving emails by applying delivery restrictions - telling the account to only receive emails from itself:
On the server running Exchange start "Active Directory Users and Computers"
Find the account.
Double click the account to open its properties (or right click and select "Properties")
On the "Exchange General" tab, click [Delivery Restrictions...].
Under "Message restrictions" check "From authenticated users only". Then select the radio button "Only from" and add the user account. It is important that you add a user account here otherwise Exchange will accept email from any authenticated user.
Click [OK] to close the "Delivery Restrictions" dialog and [OK] again to close the account properties dialog.
Using this method, to any other user it will look like the account does not exist and they will receive delivery failed messages.
This an other methods are detailed here: http://www.cryer.co.uk/brian/msexchange/exch_howto_disable_delivery.htm

How can I send an email from a Windows CE device (Compact Framework)?

I want to allow the user of the handheld device software I'm working on to send me email (the contents of a log file, which will have exception data and other info for debugging).
How can I do that? All the user should have to do, on seeing the contents of the log file (which I display to them on-demand in a form), is to mash a "send this" button. The contents of the log file (which can be read from the Textbox in which they are displaying) can be the body of the email message (rather than an attachment), with the subject line being something like "{user name} log contents"
If I have to prompt the user for their email address, that's probably okay, but I would prefer to use one of our email addresses as the sender, so that it's seen as being both from us and to us (probably two different accounts, though).
One way would to use the SDF and the OpenNETCF.Net.Mail namespace objects. It works like the System.Net.Mail objects, so sending an email would look something like this:
var message = new MailMessage();
message.From = new MailAddress("sender#mydomain.com");
message.To.Add(new MailAddress("recipient#domain.com"));
message.Subject = "Hello World";
message.Body = "This is my message body";
var client = new SmtpClient();
client.Host = "smtp.myserver.com";
client.Credentials = new SmtpCredential("myusername", "mypassword", "mydomain");
client.Send(message);

Categories

Resources