Forum » Programiranje » [ASP.NET] send mail
[ASP.NET] send mail
greentech ::
Rad bi napisal kodo za pošiljanje mailov v VB. NA netu sem našel en kup primerov in stvar tud napisal, samo ne znam pa pravilno definirat smtp.Host -- Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Uporabljam IIS- trenutno mam IP v default smtp serverju nastavljen na 169.254.70.124
smtp.Host = "169.254.70.124"
ne vem zakaj mi stvar ne deluje- upoabljam tud try pa catch pa mi ne vrne nobene napake
No celotna koda pa zgleda takole - Uporabljam System.Net.Mail class
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'' this is the .net 2.0 smtp email code
Dim sFrom = TextBox1.Text.ToString()
Dim sTo = TextBox2.Text.ToString()
Dim sSubject = TextBox3.Text.ToString()
Dim sBody = TextBox4.Text.ToString()
Dim msg As New System.Net.Mail.MailMessage
Dim addressFrom As New System.Net.Mail.MailAddress(sFrom)
Dim addressTo As New System.Net.Mail.MailAddress(sTo)
msg.IsBodyHtml = True
msg.From = addressFrom
msg.To.Add(addressTo)
msg.Subject = sSubject
msg.Body = sBody
Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
smtp.Host = "169.254.70.124"
smtp.Send(msg)
''smtp.Send(sFrom, sTo, sSubject, sBody)
Catch ex As Exception
Response.Write(ex.ToString())
End Try
End Sub
Hvala za pomoč
Uporabljam IIS- trenutno mam IP v default smtp serverju nastavljen na 169.254.70.124
smtp.Host = "169.254.70.124"
ne vem zakaj mi stvar ne deluje- upoabljam tud try pa catch pa mi ne vrne nobene napake
No celotna koda pa zgleda takole - Uporabljam System.Net.Mail class
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'' this is the .net 2.0 smtp email code
Dim sFrom = TextBox1.Text.ToString()
Dim sTo = TextBox2.Text.ToString()
Dim sSubject = TextBox3.Text.ToString()
Dim sBody = TextBox4.Text.ToString()
Dim msg As New System.Net.Mail.MailMessage
Dim addressFrom As New System.Net.Mail.MailAddress(sFrom)
Dim addressTo As New System.Net.Mail.MailAddress(sTo)
msg.IsBodyHtml = True
msg.From = addressFrom
msg.To.Add(addressTo)
msg.Subject = sSubject
msg.Body = sBody
Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
smtp.Host = "169.254.70.124"
smtp.Send(msg)
''smtp.Send(sFrom, sTo, sSubject, sBody)
Catch ex As Exception
Response.Write(ex.ToString())
End Try
End Sub
Hvala za pomoč
Microsoft ::
C# koda gre tkole:
MailMessage mm = new MailMessage();
mm.From = from;
mm.To = to;
mm.Subject = subject;
mm.Body = mailtext;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mm);
Ko to ustimas, se sprehodi v folder C:\Inetpub\mailroot\Queue in C:\Inetpub\mailroot\Drop, da nimas tu slucajno ze polno mejlov, pa ne gredo naprej. Prav tako odpri Event Viewer, ter poglej, ce ti kake evente belez.
Edit: tamle sem porpavil "localhost"...
by Miha
MailMessage mm = new MailMessage();
mm.From = from;
mm.To = to;
mm.Subject = subject;
mm.Body = mailtext;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mm);
Ko to ustimas, se sprehodi v folder C:\Inetpub\mailroot\Queue in C:\Inetpub\mailroot\Drop, da nimas tu slucajno ze polno mejlov, pa ne gredo naprej. Prav tako odpri Event Viewer, ter poglej, ce ti kake evente belez.
Edit: tamle sem porpavil "localhost"...
by Miha
s8eqaWrumatu*h-+r5wre3$ev_pheNeyut#VUbraS@e2$u5ESwE67&uhukuCh3pr
Zgodovina sprememb…
- spremenil: Microsoft ()
greentech ::
Aja..pa še to- v TextBox1 in TextBox2 vpisujem mail naslove pošiljatelja v obliki ime@gmail.com
..ne vem ali je to pomembno ampak vseeno
Pa še enkrat hvala za pomoč
..ne vem ali je to pomembno ampak vseeno
Pa še enkrat hvala za pomoč
Microsoft ::
Mail naslov je ze v pravem formatu.
by Miha
by Miha
s8eqaWrumatu*h-+r5wre3$ev_pheNeyut#VUbraS@e2$u5ESwE67&uhukuCh3pr
greentech ::
Stvar sem naštimal tako kot si napisal. Direktorija C:\Inetpub\mailroot\Queue in C:\Inetpub\mailroot\Drop sta prazna.
Zdaj mi javi naslednji error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.SmtpReplyReader.ReadLine() at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at Web_Admin_sendmail.Button1_Click(Object sender, EventArgs e) in D:\Moji Dokumenti\Grega\ASP\ASP.NET\Test\Web\Admin\sendmail.aspx.vb:line 65
Upam da se bo kdo kaj znajdel iz tega. Jaz se po pravici povedano ne preveč. Mogoče mi je jasno samo to,da je conectiomn closed..kaj moram spremnit da bo stvar delala?
Hvala
Zdaj mi javi naslednji error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.SmtpReplyReader.ReadLine() at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at Web_Admin_sendmail.Button1_Click(Object sender, EventArgs e) in D:\Moji Dokumenti\Grega\ASP\ASP.NET\Test\Web\Admin\sendmail.aspx.vb:line 65
Upam da se bo kdo kaj znajdel iz tega. Jaz se po pravici povedano ne preveč. Mogoče mi je jasno samo to,da je conectiomn closed..kaj moram spremnit da bo stvar delala?
Hvala
Microsoft ::
Jst nevem, samo takole, prekopiri prvo vrstico,
System.Net.Mail.SmtpException: Failure sending mail
in pejt na iskalnike pa isci.
Pa dej povej se kaj vec o tem SMTP serverju. Ga mas to lokalno postavljenega?
by Miha
System.Net.Mail.SmtpException: Failure sending mail
in pejt na iskalnike pa isci.
Pa dej povej se kaj vec o tem SMTP serverju. Ga mas to lokalno postavljenega?
by Miha
s8eqaWrumatu*h-+r5wre3$ev_pheNeyut#VUbraS@e2$u5ESwE67&uhukuCh3pr
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Visual BasicOddelek: Programiranje | 3454 (2480) | cekr |
» | Pomoč pri kontakt formiOddelek: Izdelava spletišč | 18502 (18400) | Vzdevek |
» | [php] mail() funkcijaOddelek: Izdelava spletišč | 1647 (1595) | t3hn0 |
» | Poslijanje majla preko SMTP (IIS); kako?Oddelek: Omrežja in internet | 1693 (1610) | Microsoft |
» | Siol does it again (strani: 1 2 3 4 )Oddelek: Novice / Omrežja / internet | 17256 (17256) | Bakunin |