Solved

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

Posted on 2004-10-04
4
277 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can i use linq for parsing string datetime to real datetime? 16 48
C# Comparing String Arrays. 5 57
Graphics 2 32
MailAddress in vb 4 29
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

790 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