Send Email with Attachment (Default Mail Client) - winforms

Right now I've been sending email with Microsoft Outlook with attachment in C#. This works great. I just got a request to achieve the same result with any email client. Is it possible to do this with a WinForm application? If so, any places for me to research on this?

Have a look at below MSDN article, has nice examples on how to use the namespace/classes
MailMessage on MSDN
On the GUI part, it might be a bit more complex (depending on how good you want to design your GUI :)). You could try to copy MS Outlook or have simple GUI with RichTextArea and couple of TextBox's with big Send button.
Another article about NET.Mail namespace

You can send email with an attachment in winforms using the System.Net.Mail namespace. You'd need to write code to cache the mail if an internet connection can't be made.
OR
You can use MAPI, which apparently can have some compatibility issues with .net.
Here's a MAPI interop project that should send email (with attachment) using whatever the default mail client is installed:
http://www.codeproject.com/KB/IP/SendFileToNET.aspx

Related

.Net Windows Form Client. Capturing Request/Response SOAP from ASMX webservice

before i decided to post this question i went thru several articles and questions in here... none of those seem to be a solution for me.... or i am doing something wrong.
I went thru this article, suggested in this site
http://www.codeproject.com/Articles/38986/Trace-SOAP-Request-Response-XML-with-TraceExtensio?msg=4152902#xx4152902xx
that's not working. Not even the source code i downloaded.
then i found this other article...
http://blog.encoresystems.net/articles/how-to-capture-soap-envelopes-when-consuming-a-web-service.aspx
This is simple.
I have a client (winform)... interacts with a webservice i have no control over, and i need to be able to capture the soap request and response. i followed like 5 tutorials so far, soapextensions, soapattributes, etc, etc... nothing seems to work for me. i have modified app.config, done everything by the book... nothing.
Question... Does anyone have a WORKING example of this? the two examples i found don't work :)
I am using Visual Studio 2010.
Have you tried using tracing in the config file as described in the MSDN articles How to: Configure Network Tracing and Configuring Tracing?
Simply use a "Service Reference" instead of a "Web Reference" then see WCF Tracing.
SOAP extensions need to be registered on the service side (that's why all posts asking you to do configuration inside web.config).
If you want to print out the SOAP messages inside your WinForms client, you will have to call web service in the "raw" way,
http://mikehadlow.blogspot.com/2006/05/making-raw-web-service-calls-with.html
#James demonstrates System.NET tracing, which is another way to see the SOAP messages in an external log file, but that's only useful for troubleshooting, as you won't receive the tracing data inside your client.

Adding attachments to workitems from silverlight

For a project we need to add attachments to workitems through a Silverlight application.
Our Silverlight app has a WCF service with which it communicates to our TFS 2010 server with the TFS API.
I can bind attachments from within the WCF service just fine, however what are the best practices to do this through Silverlight, seeing that SL is clientside and the WCF service serverside?
The way I look at it is that I need to upload the attachment to the server first, add the workitemid and the serverpath of the newly uploaded file, in some sort of log. Run a process/application on the server which searches the log for new entries, and then call the webservice which will add the attachment to the workitem.
Is this the best way to go?
Any help or suggestions would be greatly appreciated.
I would generally approach this as you described, without creating the intermediate logfile:
Upload the attachment using your SL client to the server.
Calculate the serverpath of the attachment.
Call the WCF service to process the attachment and specify the serverpath and workitem id.
Thank you Kroonwijk, for your suggestions on how to make the approach somewhat simpeler.
In the end I processed the file(s) to a byte[] on the Silverlight client side.
This byte[] is sent to the webservice accompanied by a workitemID. On the Server side(webservice) the byte[] gets saved to a temporary file on the server, and gets attached and saved to the workitem.
All works well with one WCF call, without having to use a process or file transfers to the server.
Point of notice: you might have to increase the message quota limit in your WCF bindings.

Text To Speech in Silverlight 4

I am creating an application which converts text to speech using silverlight 4.0. Two options which I found can be used are:
Use TTS at client side, which requires the application to be run OOB. Also since it uses native windows components, can't be used in any other platforms (MAC).
Use TTS conversion at WCF end. This again requires the WCF service to be hosted on IIS with Local System account for application pool.
Are there any other options in which we dont have to provide the elevated permissions?
The Bing translator service has TTS for several languages. Maybe it is possible to just use the TTS part without the translation. This blog post explains how to call the service and perform TTS from Silverlight:
http://timheuer.com/blog/archive/2010/03/22/silverlight-translator-text-to-speech-api.aspx
Another good solution is using google TTS - http://translate.google.com/translate_tts
The code would be like this:
string url = string.Format("http://translate.google.com/translate_tts?tl=en&q={0}", textToSay);
WebClient client = new WebClient();
return client.DownloadData(url);
If using silverlight, the data which is fetched from the above code(in byte array), can be set as the source of media element with converting to memore stream as below:
_audioPlayer.SetSource(new MemoryStream(textToSpeech));
Where textToSpeech is the byte array as returned from google tts.

feedback form for WP7 app

How would I go about implementing a feedback function on a windows phone 7 app? I've considered creating a form that sends an email with the data to an address I own, but I wonder if there is a better solution.
I personally think the simplest and best solution is to use EmailComposeTask to send the feedback via email.
You could either just put some questions/suggested text in the Body - or you could fill the Body in with some information from a SL form.
One of the advantages of the EmailComposeTask is you will definitely get their email address to reply to. Another advantage is that the feedback will work even when there isn't currently a network connection - it'll just get added to the outbox for later processing.
Well, I would create a webservice that can receive that data. It could be useful in case you have a backend system that can make some data statistics.
You can refer to that post that contains some code about data sending to a web service: WP7 app never exits BeginGetResponse and goes into the callback function
Regards.

Silverlight Ftp Upload

I'm working on trying to ftp a file to the server through a silverlight application. Where the location to upload the file on server file system, exists outside the sandbox area for the web server. In this case the web server root exists at "C:\test\www\" and the location to upload the file will exist at "C:\User\Uploads". In this scenerio i'm not sure if Http POST will work (doesn't that use the web server root). I just need to upload the file selected by the user to a different location that may exist outside the sandbox. With silverlight i'm thinking sockets are my last option based on the limited port range for silverlight being 4502-4532. Can i do this using WebClient and Http POST? Can i make an ftp connection through silverlight or javascript?
This is an interesting scenario, since it sounds like you are doing this all on the same machine (both client and server). I am responding to the vague original question, and would love additional data to help answer this completely.
FTP uploading itself is not supported by Silverlight, but the concept of uploading a file is, through an HTTP stream of data.
If you want to do an HTTP upload from a client machine to the server: You can use the OpenFileDialog control in Silverlight 2 and 3 to read that data, then use WebClient to upload it.
If you want to do a download from something your web server can send, to the client machine, then you'd need to use Silverlight 3 or newer, which features a SaveFileDialog control.
All Silverlight file dialogs require a user-initiated action for them to work, function, and the user will need to select the file name(s) for security purposes.
Hope this helps!
Assuming your server is ASP.NET based I would use a simple WebClient POST into a .ashx handler. Have the handler write the body of the post to a file in "C:\User\Uploads".
As long as the ftp server is on the same host as the silverlight app you can use sockets and code your own ftp client, its not very hard and there's plenty of examples out there.
In the meantime, name it Silverlight 5, Sockets got an update: with ClientAccessPolicy.xml the port-range got boosted and an in-browser elevated-trust mode is available.
Therefore I've created sharpLightFtp to enable rudimental Ftp.

Resources