Reply/ReplyAll to a particular Outlook mail using C# - c#

I want to send a reply to say a particular mail from my Outlook mailBox.
I intend to find the mail by searching the mailbox using the subject/body/sender and then reply to the found mail.
I have succeeded in searching the mail from the mailbox using C#, but i'm not able to reply to the mail.
And also if i use the reply will it be the exact replica of the action performed in outlook i.e. if replied on a mail, will the subject be added with RE: or we need to manually append the text to subject?
Please spare my Ignorance
Any help will be appreciated

The following code is an extract
Lets assume you've picked your item, here I picked one by a number..
MailItem m = objFolder.Items[t];
m.ReplyAll();
This effectively hits "ReplyAll" and fills all the things in as if outlook did it..(because it did) eg, add stuff to the body.. hit send.

Goutham gauti its right. All changes that you make in your mail item will be response. But if you want more information you can read this article on CodeProject:
http://www.codeproject.com/Articles/1106804/Create-and-send-an-email-reply-in-Csharp-VB-NET

private void ReplyToMail(Outlook.MailItem mailItem)
{
//mailItem is the mail you wand to reply to
Outlook.MailItem replyMail = mailItem.Reply();
//you can use replyAll insted
replyMail.Body = "the mail body text";
((Outlook._MailItem)replyMail).Send();
}

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

MailSystem.Net is there a way to check the status (if it is read or unread) of an email?

If anyone is familiar with MailSystem.Net, can you help me?
I would like to see the status of an email that is fetched with Imap4 and Pop3. I would like to see if the fetched email has already been read or is still unread.
int nIndex = 10;
Header EmailMessage = inbox.Fetch.HeaderObject(nIndex);
I would like to know if the fetched email is read or unread. Any help would be greatly appreciated.
With Exchange server then you can. With POP3 no as the message is downloaded. With IMAP you can with MessageInfo.Flags which has flag Flag.Seen property.
As comments above note, you can only detect if the email has been opened but not read.

WPF - add userid as prefix to orignal mail while forwarding mail

I have textbox which shows the content of mail body.
While forwarding mail original mail body if content is edited by pressing any key then user id should get appended. Please let me know how should I do this in WPF.
Before sending the mail
if(edits_made) // bool value which indicates if changes have been made
{
yourtextbox.Text.Insert(0, userid);
}
Not before sending an mail.
Similar functionality is there in outlook as well.
Add < prefix to original mail if content is modified.
Same I am trying to build in WPF.

Using MailKit, can I get the subject or sender email without downloading entire message in POP?

I have an email with yahoo business and MailKit works with POP. I want to download the message after finding a specific subject. Or could I use IMAP?
If the POP3 server supports the TOP extension, you can download just the message headers to first check the subject. To do that, you could do something like this:
if (client.Capabilities.HasFlag (Pop3Capabilities.Top)) {
var headers = client.GetMessageHeaders (index);
if (headers[HeaderId.Subject] == subject)
message = client.GetMessage (index);
}
If your Yahoo account also supports IMAP, I would recommend using IMAP since IMAP allows you to query the server for messages with a given subject which is much more efficient than downloading the headers for every message to check if the subject matches the one you are looking for.

Implementing a mailing list in .NET

I am implementing a mailing list using using .NET. As discussed in this answer, I need to send an email where the recipient of the envelope is different from the recipient in the To header. How to achieve this in C#? The SmtpClient and MailMessage classes in System.Net.Mail doens't seem to permit this.
I tried:
message.To.Add("list#example.com");
message.Headers["Envelope-to"] = "user#example.com";
but the mail doesn't get sent to what it is specified in the Envelope-to.
Any suggestions?
Adding an address to Envelope-To without adding it to To
You can use the MailMessage.Bcc property. Addresses added there will only appear in the Envelope-To, not in the mail's To:
message.Bcc.Add("user#example.com");
Adding an address to To without adding it to Envelope-To
Here, I'm quite sure you are out of luck. I've had a look at the System.Net.Mail namespace with ILSpy, and it looks like this is not possible. The To header of the mail is created out of the To property of the MailMessage (see Message.PrepareHeaders), and the same property is used to fill the Envelope-To of the mail (together with the Cc and Bcc properties, see SmtpClient.Send). Manually setting Headers["To"] won't help, since this value is overwritten with the contents of the To property (see Message.PrepareHeaders).
So, list#example.com will get a copy of the message. Depending on the configuration of your SMTP server, this might lead to a mail loop.

Categories

Resources