Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / send m / 2 сообщений из 2, страница 1 из 1
17.03.2008, 23:24
    #35196696
Fix7
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
send m
Всем привет!
Скачал код для отсилки письма с сайта. Запускаеться Но письмо не отсылает, хотя и пишет что письмо отослано. Помогите разобраться


Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">    

    void btnSubmit_Click(Object sender, EventArgs e) {

       
		MailMessage objEmail = new MailMessage();
		objEmail.To = txtTo.Text;
		objEmail.From = txtFrom.Text;
		objEmail.Cc = txtCc.Text;
		objEmail.Subject = "Test Email from the Article Working with Email using ASP.NET - Part 1";
		objEmail.Body = txtName.Text + ", " +txtComments.Text;
		objEmail.Priority = MailPriority.High;
		objEmail.BodyFormat = MailFormat.Html;
        
		
		// Make sure you have appropriate replying permissions from your local system
                //SmtpMail.SmtpServer = "localhost";

		try{
			SmtpMail.Send(objEmail);
			Response.Write("Your Email has been sent sucessfully - Thank You");
		}
		catch (Exception exc){
			Response.Write("Send failure: " + exc.ToString());
		}
    }
</script>

<html>
	<head>
	<title>E-mail and ASP.NET - Part  1 </title>
	</head>
	<body>
		<form runat="server">
                <div align="left">
                <table border="0" width="350">
					<tr>
						<td valign="top"><font face="Verdana" size="2">Name:</font></td>
						<td height="24">   <asp:TextBox runat="server" Height="25px" Width="215px" ID="txtName"></asp:TextBox>
						<br>
						<asp:RequiredFieldValidator ID = "req1" ControlToValidate = "txtFrom" Runat = "server" ErrorMessage = "Please enter your name"></asp:RequiredFieldValidator></td>
					</tr>
					<tr>
						<td valign="top"><font face="Verdana" size="2">From</font></td>
						<td height="24"> <asp:TextBox runat="server" Height="22px" Width="213px" ID="txtFrom"></asp:TextBox>
						<br>
						<asp:RegularExpressionValidator ID = "reg1" ControlToValidate = "txtFrom" Runat = "server" ErrorMessage = "Invalid Email" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator> <asp:RequiredFieldValidator ID = "req3" ControlToValidate = "txtFrom" Runat = "server" ErrorMessage = "Please enter your E-mail" ></asp:RequiredFieldValidator></td>
					</tr>
					<tr>
						<td valign="top"><font face="Verdana" size="2">To</font></td>
						<td height="24" valign="top"> 
						<asp:TextBox runat="server" Height="22px" Width="212px" ID="txtTo"></asp:TextBox>
						<br>
						<asp:RegularExpressionValidator ID = "reg2" ControlToValidate = "txtTo" Runat = "server" ErrorMessage = "Invalid Email" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
						 <asp:RequiredFieldValidator ID = "req4" ControlToValidate = "txtTo" Runat = "server" ErrorMessage = "Please enter recipients E-mail" ></asp:RequiredFieldValidator></td>
					</tr>
					<tr>
						<td valign="top"><font face="Verdana" size="2">Cc</font></td>
						<td height="24" valign="top"> 
						<asp:TextBox runat="server" Height="22px" Width="210px" ID="txtCc"></asp:TextBox>
						<br>
						<asp:RegularExpressionValidator ID = "reg3" ControlToValidate = "txtCc" Runat = "server" ErrorMessage = "Invalid Email" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
						</td>
					</tr>
					<tr>
						<td>
					</tr>
					<tr>
						<td valign="top"><font face="Verdana" size="2">Comments:</font></td>
						<td height="112"> <asp:TextBox runat="server" Height="107px" TextMode="MultiLine" Width="206px" ID="txtComments"></asp:TextBox>
						<br>
						<asp:RequiredFieldValidator ID = "req2" ControlToValidate = "txtComments" Runat = "server" ErrorMessage = "Please enter your comments"></asp:RequiredFieldValidator>
						</td>
					</tr>
					<tr>
						<td colspan="2" valign="top" height="30">
						<p align="center">


			<asp:Button Runat = server ID = btnSubmit OnClick = btnSubmit_Click Text = "Submit"></asp:Button>
						 <input type = "reset" runat = "server" value = "Clear"></td>
					</tr>
					</table>
				</div>
				
				<p> </p>
				<p><br>


			<!-- Insert content here -->
				</p>
		</form>
	</body>
</html>
...
Рейтинг: 0 / 0
Период между сообщениями больше года.
26.06.2012, 17:18
    #37855549
Syuk
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
send m
Fix7,

Добрый день.
Отправлял письма из Powershell, письмо не доставлялось, хотя и ошибки не было. Помогло поставить задержку на 500 миллисекунд сразу после отправки письма.
...
Рейтинг: 0 / 0
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / send m / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]