OutOfMemoryException when saving image - c#

I'm trying to send an email from my wcf service. Sending email works fine, but sending email with a pdf as attachment doesn't work at all. I get an OutOfMemoryException at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement). The image is loaded from an url and included in the pdf.
I've read that OutOfMemoryException doesn't have to be that the application is running out of memory. But I have another almost identical wcf service on the same windows server that works fine. The only difference with that service is the address to the server. (It's located at a subdomain) and it uses another smtp address when sending emails.
Can the problem be because the IIS site or application pool is configurated wrong? And if so, how do I solve it?
Otherwise I have no idea why it's not working.
Any ideas? Please help.

Related

How to send emails from an address without logging into the server

I'm building an asp.net application for a client that requires a confirmation email to be sent. I've gotten the code working but the only problem is that I can't get the code to work with their web host (godaddy). Is there a way to send emails with the from address marked as the clients' without having to use godaddy? (essentially faking it)
Be careful or you'll lose your emails to spam filters.
Specifically, see the Reverse PTR record discussion here:
http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

EWS: How to upload attachment first before sending an email?

I use Exchange Web Service API to do sending email. It is very easy to add attachments by just writing
message.Attachments.AddFileAttachment(attachmentname);
The problem is attaching process happens in sending process. I found that yahoo, gmail and hotmail they all uploading attachmetns first before you sending the mail. How to do so?
It's the EWS Managed API which does this uploading and sending in one process. But in the background, multiple requests are made to the Exchange server:
Create the message in the Drafts folder of your mailbox
Upload the attachments
Send the items.
If you want to, you can do this yourself. But I don't see the point in doing that. What do you want to accomplish?
If you notice, GMail for example does not use the same manner of attachment. For instance, when you attach something, I am guessing the files get uploaded to some server and then they just provide you with a Link for the download. So I think you can upload the file to some server (be it FTP, or just a database) and then just add the links to the download of the files in the body of the email.
Good luck. I will be looking into the thread to see if there is in fact a way to do this.
Hanlet

Sending Email-SMTP Problem-C#.NET

I am struggling with this problem from yesterday.
What I have done so far?
I have used the code to send an email using local smtp server. Code is(C#.Net) Here.
I can telnet the localhost on port 25.
When I telnet: "220 DomainName Microsoft6 ESMTP Mail Service, Version 6.0.3790.3959 Ready at Date Time "
When I try to send the email, there are no errors in the code and code gets executed successfully without any error.
Errors:
When I check in the eventviewer, the error is : Message Delivery to Host 74.125.159.27 failed while delivering to the remote domain gmail.com for the following reason. The remote server did not respond to a connection attempt.
I know there is error in my SMTP Server Setup, I have not set it up properly. How do I Trouble shoot it.
I have downloaded a smtpdiag.exe from microsoft but, It doesn't do anything when clicking on .exe file loads up and disappears.
Resolutions Please?
Please help me how do I troubleshoot it. If you need more information please ask me, I will provide but try to help me
Thank you.
You are sending emails through IIS SMTP Server right?
And you are sending to your gmail address?
How OFTEN do you send them? Google as a kind of spam protection that fakes that the servers is not responding if an IP address tries to send too many emails at once.
There is a thread here at SO about it. But I can't seem to find it.

Receiving data sent from client machine

I'm working on a project that has a C# app (running 24/7 as a server) on the client's machine). This app needs to send a file as a byte stream via POST to a server I am currently hosting on my home desktop.
Can this file be received by a C# app running on my server, or does it have to be as ASP app/page?
Also, I know how to send a bytestream via POST, but how will I set my server side app to listen for this incoming data?
I have never done something like this, so I'm looking for some pointers to get me started.
Thanks
Depending on what you need to do with the file, and when it's uploaded, there is nothing wrong with using a tiny asp.net app to do this.
If the only way you can get the file to the server is via http POST, why write your own service/daemon to run a listener? Unless you have some reason not to run it in IIS, I would do it there. There is the full stack available that way for authentication and so on if you should happen to need it. Besides, if you have to upload files via http post, I would bet you will end up wanting other methods available via HTTP as well..
You're looking for this guy:
http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
Using that, you'll create basically a mini HTTP server, listening on some port you specify. You'll then be able to post data to it, and process it accordingly (similar to if the processing code was in an ASPX code-behind).
Assuming your open to sending directly via TCP you can look at this example if you dont wanna go the HTTP way. I personaly like the NetworkStream Class, for sending data over the network painfree.

Setting up a SMTP mail server

Our e-commerce site requires the sending of email
Currently, for some odd reason, the server that is being used to do this is the database server... which clearly isn't ideal (i've just taken over here)
My idea is this -
to write a windows service that checks for new mails that need sending (these are all in a sql db) and then process the mails seperately...
I want to use a seperate mail server, to keep this efficient..
Has anyone had any experience of this?
Would it be sensible to (for example) set up a lightweight debian (or other distro) machine, with exim on?
Would i be able to use that as the host ip address when specifying my smtp server to send email?
I'm going to be using C#....
I've done this quite a bit, and sometimes I've used a windows server running the SMTP service, other times we've used a third party. In either case you set the host of the mail server in the configuration file and your application can pick it up and continue working.
A nice thing about using a third party service, is that you should have less concern about being black listed.
We did something very similar. We used the IIS SMTP server and wrote code in C# to pump messages directly into its pickup directory using SmtpDeliveryMethod.PickupDirectoryFromIis. systemnetmail.com has some sample code that may help you.
One thing to be careful of is race conditions in the database, especially if you are sending messages with more than one thread (which we were doing). We implemented a queue in the database and used the UPDLOCK and READPAST hints in SQL Server for maximum performance. I think we got it up to over 10,000 emails a minute this way.
You can use the Windows SMTP server wich you can access and use from your web or console application using the CDOSYS or CDO object. You can use this link about configuring the SMTP server on Windows 2003

Categories

Resources