Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-04
4
Medium Priority
?
302 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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