PDA

Click to See Complete Forum and Search --> : Sending Email without using SMTPServer details


afterMoon
May 23rd, 2003, 01:14 PM
Hi all,
I need to send a mail from my web page. I got the sample to send the mail using system.web.mail class and thus by creating an object of mailmessgae(). But there I have to give the value for SmtpMail.SmtpServer. I'm not sure about the clients SMTP server details.
Is there any other way to send mail without giving the value of SmtpMail.SmtpServer?.
I think this was possible with ASP's CDONTS. Is there any equivalent code in ASP.NET?

PLease help

hellswraith
May 23rd, 2003, 04:47 PM
If your sending the mail from your page, you use your smtp server.

So, if your page is www.something.com you will probably use mail.something.com as the smtp server (you will have to check with your hosting company for the exact one). All you are doing is setting how your asp.net app is going to send the mail. It has nothing to do with the client.

afterMoon
May 24th, 2003, 12:38 AM
yes. I meant the hosting company not the client :p

But In classic ASP, that can be done without giving those address. right?.
And that means In case if I'm doing a site for a third party who is not decided where and when to host yet, what would I do?.
Should I 've change the code then?

Thanks Mr.hellswraith for your response.

hellswraith
May 24th, 2003, 10:30 AM
Take a look at this thread:
http://www.vbforums.com/showthread.php?s=&threadid=246409

It gives a way to store the connection string in the web.config file. You can do the same for the smtp server. Since the web.config file is just an xml file, the end user can open it up, add in their smtp server, and they are done.

You just need to give them instructions on how to perform this (open the file in notepad, find the smtp server element, change to their smtpserver).

Also, with traditional ASP, you relied on 3rd party components to send mail. They also require a smtp server. If you host had these components installed, then they configured them for your use already, that is why you never had to deal with it.

afterMoon
May 26th, 2003, 04:53 AM
Thanks again Mr.Hellswraith.
Nice solution. Thanks.

... and in traditional ASP I just used the CDONTS object. The code sequence was as follows..

Set objMsg = Server.CreateObject("CDONTS.NewMail")
objMsg.BodyFormat = 0
objMsg.MailFormat = 0
objMsg.From = "me@myself.com"
objMsg.To = "you@yourself.com"
objMsg.Subject = "Greeting"
objMsg.Body = "Hi"
objMsg.Send
Set objMsg = Nothing

any suggestions?

hellswraith
May 26th, 2003, 10:45 AM
You may have, but I used something like jmail or something. So, this would pose a problem when you tried to distribute your code, because you didn't know what object the person had on their server. If I released code for jmail, and sent it to you, you wouldn't be able to use it unless you also had jmail, or you would have to re write the code to make it work with your CDONTS object.

Now with the .Net framework, we don't have to worry. The only thing that needs to be configured is the smtp server.

Good luck.

afterMoon
May 27th, 2003, 01:31 AM
Okey Mr.Hellswraith, I have to it in .NET anyway.

Thanks for your patience