Solved

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

Posted on 2004-10-04
4
264 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
Comment Utility
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_
Comment Utility
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
Comment Utility
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_
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now