Solved

send a .jpg using smtp from windows forms application in C#

Posted on 2004-10-04
4
275 Views
Last Modified: 2010-04-15
Hi!

below is the smtp code i am using, i got the exceptions
'System.Web.HttpException' occurred in system.web.dll
Additional information: Could not access 'CDO.Message' object.
so in smtp virtual server properties->Access->relay selected 'all except the list below' and both above exceptions went away
but still no email was sent by the code when i checked my hotmail account
i tried using both the strings for SmtpServer = "127.0.0.1";  //"localhost"

try{
               MailMessage mail = new MailMessage();
               mail.To = "emailme@hotmail.com";
      mail.From = "emailme@hotmail.com";
      mail.Subject = "this is a test email.";
      mail.Body = "this is my test email body.";
      MailAttachment attachment = new MailAttachment( @"D:\1\trial\ProjectWorkSpace5\3769.jpg" );       mail.Attachments.Add( attachment );      
      SmtpMail.SmtpServer = "127.0.0.1";  //"localhost"
      SmtpMail.Send( mail );
      mail=null;
      attachment=null;
    }
catch(Exception ex)
   {
      MessageBox.Show("Error  :"+ex.ToString());
   }

now why would it not send the email?! ....thank you in advance for your assistance
0
Comment
Question by:srao0
  • 2
4 Comments
 
LVL 6

Expert Comment

by:mogun
ID: 12224402
Is a smtp server running in your localhost?  If not try giving the IP address of the smtp server...If your localhost has an smtp server running, try giving the ip address of your machine instead of the 127.0.0.1...

Cheers
Mohan
0
 
LVL 8

Expert Comment

by:Razzie_
ID: 12225907
I think this is an SMTP server configuration problem...

Have you tried sending an email using telnet or OE to your hotmail account? Maybe DNS settings are not configured, or wrongly. Try sending a plain text message through telnet and if still no mail in your hotmail inbox, you know it is a config error
0
 
LVL 15

Accepted Solution

by:
deepaknet earned 125 total points
ID: 12226053
Hi:

System.Web.Mail does not give a clear picture of the failure at the first view. You may need to check out the InnerException since the Exception will always give 'Could not give CDO Message'

When you get the exception, see the InnerException and see the message it contains.

Check out: http://www.systemwebmail.com/

Alternatively, if you Interop, you can use Persits.MailSender (http://www.persits.com/)
0
 
LVL 8

Expert Comment

by:Razzie_
ID: 12232090
scrac0,

do you have other service installed on the local machine, like Exchange? Also, have you checked that your SMTP server is actually running (you can check that in IIS).
If it doesn't work, go through every setting of your SMTP server. Are there IP restrictions that shouldn't be there? Check if anonymous authentication is turned on, etc.

In any case, I can tell you it is not a C# problem, but a SMTP server config error. Granted, I don't know that much about it, so if you can't get it fixed, might want to ask this in the Email / Groupware TA.

HTH,

Razzie

ps. Please respond in the question not member feedback since I don't read the latter that often :)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question