?
Solved

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

Posted on 2004-10-04
4
Medium Priority
?
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 375 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 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