Sending mail from page

  • Thread starter Thread starter Zile
  • Start date Start date
Z

Zile

I am trying to send mail from web page in asp.net 2.0/VB 2005:

Dim Poruka As New System.Web.Mail.MailMessage

myMessage.From = "(e-mail address removed)"
myMessage.To = "(e-mail address removed)"
myMessage.Subject = "Automatic sending mail"
myMessage.Body = "Success!"
Mail.SmtpMail.Send(myMessage)

There is no error message! Only message that recomended is
System.Net.Mail.MailMessage instead System.Web.Mail.MailMessage.
Compiling is ok, but messages is not sent. I changed myMessage.To adresses,
but nothing! How to fix it?

Thanks
 
Hi,

I do not think your smtp server is sending the message. You might
want to connect to a smtp server to send them

Dim client As New SmtpClient("mail.YourServer.com")
client.Credentials = New Net.NetworkCredential("UserName",
"YourPassword")
Dim mm As New MailMessage("(e-mail address removed)",
"(e-mail address removed)")
mm.Subject = "Automatic sending mail"
mm.Body = "Success!"

Try
client.Send(mm)
Catch ex As Exception
' handle the error
End Try

Ken
 
Again! Compile is ok, but mail is not comming. What can be problem? I am
running this aspx page on my local server on my computer it is not on web
hosting account. Is this can be a problem? Which smtp server I must to put,
from my web hosting account or from my outlook express if I am running aspx
on my computer?
 
Which smtp server I must to put, from my web hosting account or from my
outlook express if I am running aspx on my computer?

Whichever one allows you to send emails from your local computer.

E.g. my hosting service is hostinguk.net, and they allow web applications
deployed on their servers to send outgoing email using their SMTP queue on
relay.hostinguk.net.

However, this will not work from my local machine because that SMTP queue
will not recognise it as part of its internal network, otherwise they'd be
inundated with spammers relaying email through their servers...

Therefore, when I'm developing and testing from home, I need to use my ISP's
SMTP queue, which is smtp.blueyonder.co.uk - at this point, the email can be
sent because that SMTP queue recognises my machine as valid on their network
because it has been assigned an IP address from their DHCP pool.
 
Couple of things:

1) you must have access to a smtp server that can relay mail on your
behalf.
2) Said smtp server must be configured to allow relay of email

If you have established this you can modify your code as follows:

myMessage.From = "(e-mail address removed)"
myMessage.To = "(e-mail address removed)"
myMessage.Subject = "Automatic sending mail"
myMessage.Body = "Success!"
'Replace mail.server.com with your smtp server
SmtpMail.SmtpServer = "mail.server.com"
SmtpMail.Send(Message)
 
Back
Top