473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Configuring SMTP for emails

Hi,

I'm using this code for sending emails and its working fine because I had
configured SMTP in my machine in IIS.

now I'm using machine as a server for this application. but when running the
same application from other machine the email process is not working.

so, do I have to configure and install SMTP in all client machine to get it
working!? or should it be enough just to set it in the server machine?

MailMessage objMailMsg = new MailMessage(strFrom, strTo);

objMailMsg.BodyEncoding = Encoding.UTF8;

objMailMsg.Subject = strSubject;

objMailMsg.Body = strMsg;

Attachment at = new Attachment(Server.MapPath(AttachmentPath));

objMailMsg.Attachments.Add(at);

objMailMsg.Priority = MailPriority.High;

objMailMsg.IsBodyHtml = true;

//prepare to send mail via SMTP transport

SmtpClient objSMTPClient = new SmtpClient();

objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

objSMTPClient.Send(objMailMsg);

Thanks

--
Regards,
M.Rochdi
Sep 12 '07 #1
5 5071
Just on the server, as ASP.Net is a server-side technology.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Mike" <Mi**@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
Hi,

I'm using this code for sending emails and its working fine because I had
configured SMTP in my machine in IIS.

now I'm using machine as a server for this application. but when running
the
same application from other machine the email process is not working.

so, do I have to configure and install SMTP in all client machine to get
it
working!? or should it be enough just to set it in the server machine?

MailMessage objMailMsg = new MailMessage(strFrom, strTo);

objMailMsg.BodyEncoding = Encoding.UTF8;

objMailMsg.Subject = strSubject;

objMailMsg.Body = strMsg;

Attachment at = new Attachment(Server.MapPath(AttachmentPath));

objMailMsg.Attachments.Add(at);

objMailMsg.Priority = MailPriority.High;

objMailMsg.IsBodyHtml = true;

//prepare to send mail via SMTP transport

SmtpClient objSMTPClient = new SmtpClient();

objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

objSMTPClient.Send(objMailMsg);

Thanks

--
Regards,
M.Rochdi

Sep 12 '07 #2
Hello,

Kevin it's right, the code to send an e-mail is sent in the server side.

Maybe there has been some changes on your SMTP server, or there is some
security restriction with the ASPNET user that runs under IIS.

I would try:

- First check if you really can send an e-mail from the server machine
now (not using .net code, using telnet, you can find this a link below).

- If you can send an e-mail using that user and password, now let's try
with the ASP .net accessing from your localhost, if you cannot try in the IIS
to use a different account (just something temporary) to ensure that is not a
permission issue.

- I would check as well if there is some restriction or rules on the SMTP
server where you rely, sometimes for instance the from must have a given a
domain name, or you shoulw login using Basic Authentication or NTLM.

More info about .net framework support to SMTP:

http://www.tipsdotnet.com/ArticleBlo...TP&PageIndex=0

Good luck
Braulio
/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------


"Mike" wrote:
Hi,

I'm using this code for sending emails and its working fine because I had
configured SMTP in my machine in IIS.

now I'm using machine as a server for this application. but when running the
same application from other machine the email process is not working.

so, do I have to configure and install SMTP in all client machine to get it
working!? or should it be enough just to set it in the server machine?

MailMessage objMailMsg = new MailMessage(strFrom, strTo);

objMailMsg.BodyEncoding = Encoding.UTF8;

objMailMsg.Subject = strSubject;

objMailMsg.Body = strMsg;

Attachment at = new Attachment(Server.MapPath(AttachmentPath));

objMailMsg.Attachments.Add(at);

objMailMsg.Priority = MailPriority.High;

objMailMsg.IsBodyHtml = true;

//prepare to send mail via SMTP transport

SmtpClient objSMTPClient = new SmtpClient();

objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

objSMTPClient.Send(objMailMsg);

Thanks

--
Regards,
M.Rochdi
Sep 12 '07 #3
You need to add the smtp server name, see below. from what you say I assume
that you had it working on a machine that had smtp, but now you are on a
different machine, you need to tell smtpclient what machine has smtp
remeber to add
"using System.Net.Mail;"
to the top of your page

MailMessage message = new
MailMessage("te**@here.com","so*****@there.com");
message.Subject = "Test";
message.Body = "this is the body";
SmtpClient emailClient = new SmtpClient("aSMTPserver");
emailClient.Send(message);


"Mike" <Mi**@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
Hi,

I'm using this code for sending emails and its working fine because I had
configured SMTP in my machine in IIS.

now I'm using machine as a server for this application. but when running
the
same application from other machine the email process is not working.

so, do I have to configure and install SMTP in all client machine to get
it
working!? or should it be enough just to set it in the server machine?

MailMessage objMailMsg = new MailMessage(strFrom, strTo);

objMailMsg.BodyEncoding = Encoding.UTF8;

objMailMsg.Subject = strSubject;

objMailMsg.Body = strMsg;

Attachment at = new Attachment(Server.MapPath(AttachmentPath));

objMailMsg.Attachments.Add(at);

objMailMsg.Priority = MailPriority.High;

objMailMsg.IsBodyHtml = true;

//prepare to send mail via SMTP transport

SmtpClient objSMTPClient = new SmtpClient();

objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

objSMTPClient.Send(objMailMsg);

Thanks

--
Regards,
M.Rochdi
Sep 12 '07 #4
You need to specify the host for the SMTP service :

SmtpClient objSMTPClient = new SmtpClient("mail.server.com");

or

SmtpClient objSMTPClient = new SmtpClient("111.111.111.111");
( using the IP address, instead of the SMTP host's name )


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Mike" <Mi**@discussions.microsoft.comwrote in message news:58**********************************@microsof t.com...
Hi,

I'm using this code for sending emails and its working fine because I had
configured SMTP in my machine in IIS.

now I'm using machine as a server for this application. but when running the
same application from other machine the email process is not working.

so, do I have to configure and install SMTP in all client machine to get it
working!? or should it be enough just to set it in the server machine?

MailMessage objMailMsg = new MailMessage(strFrom, strTo);

objMailMsg.BodyEncoding = Encoding.UTF8;

objMailMsg.Subject = strSubject;

objMailMsg.Body = strMsg;

Attachment at = new Attachment(Server.MapPath(AttachmentPath));

objMailMsg.Attachments.Add(at);

objMailMsg.Priority = MailPriority.High;

objMailMsg.IsBodyHtml = true;

//prepare to send mail via SMTP transport

SmtpClient objSMTPClient = new SmtpClient();

objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

objSMTPClient.Send(objMailMsg);

Thanks

--
Regards,
M.Rochdi

Sep 12 '07 #5
Hi,

Juan T. Llibre schrieb:
You need to specify the host for the SMTP service :
SmtpClient objSMTPClient = new SmtpClient("mail.server.com");
on a side note, I would recommend not to hard-code mail server and other
settings but use .NETs built-in feature to read those from the
web.config file. Otherwise you have to recompile the application when
something changes or when you deploy your site to production.

Mike, also note that
>//prepare to send mail via SMTP transport
SmtpClient objSMTPClient = new SmtpClient();
objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
objSMTPClient.Send(objMailMsg);
this does NOT send via SMTP but writes the mail to the pickup directory
of IIS. That's all good if some mail agent on your server is configured
to pick the mails up there, otherwise you have to change the Delivery
Method to something else (I believe it's "Network") and supply
credentials for the SMTP server.

Hope this helps,

Roland
Sep 13 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Emmett Power | last post by:
Hi, I use Access to send emails through SMTP. I'd like to mirror the process and retrieve emails from my SMTP/Pop3 server without the intermediary of Outlook. I don't want to spend a lot of...
3
by: Serdar C. | last post by:
how can i connect to a smtp server and check my email account if i have e mails and maybe looking at their subject, etc,.. couldnt fnd a place for smtp commands and cnonecting to a smtp server??
4
by: Brett Porter | last post by:
Hi, My ASP.Net applications frequently make use of the System.Web.Mail namespace to send emails. I have set SmtpMail.SmtpServer = "localhost" and the emails send out fine UNTIL an email is sent...
6
by: Brian M | last post by:
I have an ASP.NET application using .NET Framework 1.1 running on a Windows 2003 server. The application uses SMTP to send emails. This application was moved from an IIS 5 machine where it worked...
11
by: JD | last post by:
Is it possible using the smtp class in asp.net to send emails and authenticate to the mail server that is sending the emails out. Currently I have a web application that works fine on my machine,...
11
by: ibiza | last post by:
Hi all, I am trying to use the System.Net.Mail class for the first time, with ASP.NET 2.0. I setup everything according to http://www.codeproject.com/aspnet/EasySMTP_package.asp, which gives...
4
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. ...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, My company will be hosting a webcast, and I need to send out 2000 individual emails to people who signed up (for login information...). I created an smtp app that I can loop through...
1
by: rada.lambretha | last post by:
Configuring Linux as a Firewall * Making installation choices * Introducing iptables * Using iptables commands * Simplifying things with firewall GUIs * Adding proxy functionality As...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.