How to set a mailmessage as an attachment on another mailmessage - c#

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.

Related

How to Implement Forward To in SendGrid

I have checked the documentation of Send Grid but can't see any feature like Forward To , Can anyone let me know if there is any way to implement this feature like is already there. I need to know about Forward.
Any help would be appreciated.
What do you mean by "forward to"? Forwarding an email is a client-side function, not part of SMTP. SendGrid doesn't provide POP/IMAP mailboxes so there's no way to automatically forward messages received if that's what you mean. You might be able to use the Inbound Parse webhook but you would have to write some code.

Outlook 2003+ Embedding signatures with images to all sent emails

I have a Win Form application that does some boring accounting stuff and then sends it's data to some lucky recipients. I am using the Outlook 12.0 Interop objects and my applications environment ranges from office 2003 on XP to office 2007 on Win 7.
My issue lies with sending the corporate signature with the sent emails.
It contains two images and I would like to embed these images so they appear to be part of the body (assuming the receiving mail client supports that).
I have tried a few different methods of accomplishing this; but still no luck!
I have tried:
Extracting the html data from the signatures folder, changing the
html img tags src attribute to include 'file///'. This causes Outlook
to replace the 'file///' with 'CID' and I assumed it would also embed
the image... we should never assume :|. This is the method I found
worked best for getting the rest of the signature.
(After creating a new MailItem) - Grabbing the HTMLBody of the MailItem
and extracting the relevant part including the signature... This
didnt work due to the new MailItem object being very inconsistent
with it's signature. By that I mean sometimes the new item would
include the signature and sometimes it wouldn't! :s I cannot figure out why it is not always there, no other part of my code has changed!
I read on another post here about the GetInspector property... Apparently just calling this will do 'Some stuff' and the signature will magically appear in your mail item... NO!
Things I can't do:
I cannot (as much as i would like to) shove the images online
somewhere and point to them in the emails html.
I cannot use SMTP(It has to be through Outlook... sigh).
I am thinking that the best way seems to be my original method of messing about with the CID, but I do not really know much about what Outlook is doing in the background so I am having trouble figuring out what else I need to do to get the images sent along with the email.
Hoping someone out there has some idea about what I am doing wrong or what else I could try.
Please let me know if code would be helpful and I will post, (Most of the code tried is from this site... I just cannot find the links again and am trying to avoid making this question tooooo long).
Many thanks
This is not the most efficient or flexible solution you can use, but probably the most robust and portable. You can convert your image bitmap into plain HTML and embed that HTML in your e-mail signature.
The conversion is quite simple, you can use the utility I wrote (open source) here.

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

Good Library for Creating E-mail Templates with Merge Ability

I'm looking for a really good library/component/framework for creating e-mail templates for my web application.
We send out a number of e-mails on a regular basis:
Activate Your Account
Welcome
Thanks for Your Order
Etc.
I'd like to give the non-technical administrators of my web app a way to:
See the current e-mail template (HTML, WYSIWYG)
Make some minor modifications to copy, colors, etc.
Preview, Test, Save, and "deploy" a new version of the e-mail template.
The tool needs to support "merge" fields. For an example, see MailChimp.com. They allow users to create e-mail templates and then specify any number of fields like this:
|FIELD1|
|FIELD2|
Then, when sending an e-mail, the developer passes-in the appropriate info for each field.
An example:
Hi *|FIRSTNAME|*,
Thanks for signing up. You rule!
Best regards,
MyWebSite.com
Does anyone know of a tool like this that can plug into my ASP.NET / C# web app? I assume someone out their wrote a library/component/something that I can license.
Thanks!
Try this one. It's free and open source:
http://mailsystem.codeplex.com/
It includes some classes specifically designed for mail merging
What's nice is that you can use its mail merging capabilities and still use system.net.mail for sending the email to avoid breaking your code.
Here is another option.
http://ntemplates.codeplex.com/

integrating two systems through email

I want to integrate our bug tracker system and our Support system through emails.
The bug tracker can kick out an email on every change to bugs/features. I want to download those emails, parse them and create a formatted email that the Support system can understand (ie the subject could be "Issue #4128 fixed").
What is the simplest way to accomplish this using C++ or C#?
Martin, I'd say there's no "simplest" way to do this. The easy part is downloading the e-mail. (If that's what you need help with, say so and I'll post some C# code that does this.) How you parse the e-mail depends on the format of the message.
For instance, if the body of the message contains the data you want to provide to your support system, your approach will be different than if that data is included as an attachment to the message.
With more information, I'm sure we can be more helpful.

Categories