MailKit/MimeKit.NET - Remove quoted messages within a replying email (from Outlook) - c#

I want to strip the entire past mails to get the original mail body without any quotations using MailKit/MimeKit.
Getting the mails (via IMAP) is already done and working fine. But in case of a replying mail, the history of the written mails should be completely removed to get the original mail body by itself. The mainly used mail client is Outlook (customer), but also Thunderbird is in use of the support team.
I know, that there is this question, but this solves only the part for building the mail body for a reply (with all existing messages as quotation).
This functionality would be used for a ticket system.
How would you folks handle the deletion of the quotation from outlook?
(And maybe a more Outlook behavior of adding the existing mails as a quotation)

It sounds like what you want to do is the reverse of the other question.
The simple answer to that is to remove all lines that begin with ">" (or perhaps more specifically, lines that begin with "> ").
Then you'll also want to remove the line above the first line starting with a ">" (or "> ") - at least if it seems to have a date string in it.
Unfortunately it's not likely that a library exists to do this, so you'll probably have to write your own logic, but I could be wrong.
Hope that helps.

Related

How to set a mailmessage as an attachment on another mailmessage

I have two mailmessages, I want to attach one two the other in vb.net or c#.
How do I do this?
I've had a look at msdn's pages for MailMessage and Attachment but can't wrap my head around it.
I've managed to send other files as attachments, do I do it in the same way? If so what mime type/MediaTypeNames would I use?
I've tried searching online (including SO) but all results are for attaching files etc (which are streams - I don't think mailmessage is?)
I'm sure it must be possible and I think I must be overthinking it, I hope someone can point me in the right direction.
Use Case
Just to clarify why I want to do this, its essentially a simple method to see the email exactly as it was generated, without sending it to the recipient(s) but preserving that metadata. Unit tests are well and good but being able to see the exact email in a browser (and show it to stakeholders) is invaluable.
Given your use case I would suggest a different approach (I use it myself to test SendMail): send your mail in a local directory as an eml.
Then you can use an email client to see the mail, or just explore it as a textfile to check the raw structure.
How to do it? Just configure your SMTP client class to deliver the mail localy when you want to test:
SmtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
SmtpClient.PickupDirectoryLocation = directoryDelivery;
Hope it helps.

Tabs in email not equal over different email browsers

In the asp.net (c#) application that im using/ building I am sending an email with spacing between words u use Tabs in the body but they never seem to be acting the same when going to an other email browser.
Is there a way to get them to act the same in Gmail and Outlook of even in Outlook 14.0 and 15.0?
Name:{{ Customer.Surname}}
Email: {{ Customer.Email}}
You could format your mail body as HTML and provide a stylesheet that specifies the spacing. A lot more work than just throwing tabs in, but the results will be more consistent.
I'm not sure I understand your question correctly, but you cannot use tabs to format emails reliably.
If you want to format your emails you need to create emails with an html part that includes the formatting that you need.

outlook removing my new lines (i have already tried everything mentioned to trick outlook)

so i have an email body I need to send in an email in outlook using a program I wrote in C#.
The body string has newline characters in it. I have tried everything to keep outlook from filtering them out. I even have the take out new lines option disabled and it still does it. I have tried every trick i could find on the web. I have tried Enviroment.NewLine and \r\n and anything else. It is so frustrating. Does anyone have any explanation???
If the message is sent as plaintext, most recent versions of Outlook will remove whatever it determines as extraneous newlines in the message to improve readability. Only the end user with the Outlook client has the ability to override this behavior and can do so on a message by message basis.
If you would like to have more control over the layout and formatting of the message, then you should generate your message body as an HTML message rather than a plaintext message. Of course this means that you have to do a little more work to create the message layout you want to use, but it will result in a very nice presentation and gives you much more control over things like vertical alignment and such that you cannot do reliably using just plaintext alone.

how check a validated Email Exist Or Not Without Sending test Email by c# codes?

how can we check that a validated Email exist Or Not Without Sending test Email by c# codes?
we can check Validation of that email by many ways...
but what about existence?
is it possible to do that or not ?
thanks in advance
You should look at these websites. I've used a similar method to these three in the past when validating users emails for a federal website that required an authentic email address.
http://tools.email-checker.com/
http://verify-email.org/
http://www.technixupdate.com/check-whether-an-email-id-is-valid-or-not/
A mail server will usually quickly send back a response telling you if the email is valid or not, that is what you're going to be looking for.
As well, SO already has a few posts on this:
Checking if an email address exists
is one of them.
Update:
I love the existence tag...!
You could possibly use C# to run a cmd command - telnet. Then output the results to a text file and read them into to your C# app. This should help - http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email You will need to know the details for the mail server names though. You might be able to do this directly from C# but I have only done it through telnet.
I don't know if there's a good way to do what you're looking for, but a solution that might get you part of the way there is to ping the domain to at least make sure that exists.
Here's an MSDN link which explains how to ping from .NET:
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx
You can use a Regex Validation on the form before the user submits the data. It's an inbuilt tool in Microsoft Visual Studio where you can pretty much drag and drop :)
You should be able to find it in the validation section . Regular expression Validator

Is there a way to automatically re-send an email according to certain rules with Outlook 2007 and MS Exchange?

I am looking for a solution to the following problem:
My manager wants to automatically send a second message when he sends an email to X and there is no response in two days. If there is no further response in 2 more days, send another message.
Before I start building anything, I wonder if there is already a product/solution that does that? Can anybody recommend an already existing tool?
We use MS Exchange and he uses Outlook 2007.
Auto Follow Up is a tool I've used in the past for this specific purpose. Also, always check www.slipstick.com for listings of Outlook/Exchange add-ins - they seem to be the best source (disclaimer: I have no affiliation with that site or any of its add-ins)
It's not an existing solution, but in case you don't get any answers:
You can use Exchange Web Services to do this: pointing it at his Sent Items folder. So this is basically what you would do:
Use SyncFolderItems against his Sent Items, say every 1 hour. The first time you do this use null as the SyncState, thereafter use the last SyncState the server sent you.
Write them to a SQL table: { ItemId NVARCHAR(MAX), ChangeKey NVARCHAR(MAX), MessageID NVARCHAR(MAX), Sent DATETIME }. MessageID would be the Message-ID header from the message.
Run a query (say once a day) that selects the rows where the Sent value is more than 2 days ago.
Use GetItem to retrieve the original mail and resend (first clearing/deleting Message-ID) it using SendItem.
Delete the selected rows.
These items will land up in the Sent Items folder and will be picked up by your application (as they are actually new mails); and re-processed in 2 days.
Use SyncFolderItems against his Inbox, again maybe every hour (maybe immediately after the first operation against Sent Items). Keep a unique SyncState for this operation.
Grab the In-Reply-To header. Delete any rows with a maching MessageID.
Grab the References header; and split it into a list. Delete any rows with a matching MessageID.
Would this solve your problem:
http://www.followupthen.com/
Perhaps not exactly what you want and it isn't integrated into Outlook.
I don't think you will find exactly what you want. This is functionality which belongs to a CRM, not to email software.
Having said that, the Getting Things Done Outlook Add-In will get you in that direction. It won't automatically send a follow up mail, but it can take care of a notification so you send it yourself. (but this plugin is not free - $75 - you have to decide yourself if that's worth it)
With the GTD add-in you can send a mail, and select the option "Send and Action". After pressing send mail, you can select the action "#Waiting For", and press ok. Now it will create an outlook task, with the subject and contents of the email you sent automatically filled. You can set all the task properties, like end date and notification time.
After two days at the notification time, you get a (default) outlook popup, where you can open the task. With one click you can open the corresponding email and use reply or forward to send your followup. You can create a new task or modify the existing task for the next followup.
If you receive a reply in the mean time, and open the mail, you can use the "related task" button to find the corresponding task to mark it as complete. It also adds buttons like defer and delegate to your mail.
There is a 30-day trial. I am not connected to netcentrics, but I have bought and use this plugin.
Have you looked into automating Outlook using Visual Basic for Applications? If you aren't familiar with VBA, or if the thought of writing VBA gives you nightmares (I've had a few), then you might find some example VBA code on the web that accomplishes something similar to what you are trying to do, and then you could just tweak it. I know you said that you wanted an existing tool, but I thought I would throw this out there as a sort of last resort. It's not ideal, but I'm pretty sure it would solve your problem.

Categories