attaee
یک شنبه 14 اسفند 1390, 15:22 عصر
با سلام برای ارسال میل مشکل دارم ایم کد ارسال میلم هست اما از تصویر امنیتی هم در این فرم استفاده میکنم اما نمی دونم کجاش مشکل داره که وقتی اعتبار سنجی میکنه ارسال فرم رو میزینی صفحه ای که میگه فرم ارسال شد میاد اما هیچ میلی ارسال نمیشه؟ اما وقتی فرم رو ارسال میزنی و اعتبار سنجی درست نیست میل ارسال میشه ؟؟؟؟؟؟؟؟؟؟؟؟؟ ترو خدا کمک کنید خیلی ضروریه؟؟؟؟؟؟؟؟
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Text
Imports System.Net
Imports System.Net.Mail
Imports System.IO
Imports System.Drawing.Text
Imports System.Drawing.Imaging
Imports System.Security.Cryptography
Imports System.Drawing
Public Partial Class _Feedback
Inherits System.Web.UI.Page
Public Function CreateSalt() As String
Dim rnd As New Random
Return rnd.Next(1000000, 9993989)
End Function
Public Function CreateImage(ByVal path As String, ByVal height As Integer, ByVal width As Integer) As String
Dim r As New Random
Dim salt As String = CreateSalt()
Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(bmp)
g.TextRenderingHint = TextRenderingHint.AntiAlias
g.Clear(Color.WhiteSmoke)
Dim mymat As New System.Drawing.Drawing2D.Matrix
Dim i As Integer
For i = 0 To Len(salt) - 1
mymat.Reset()
mymat.RotateAt(r.Next(-19, 0), New PointF(width * (0.1 * i), height * 0.25))
g.Transform = mymat
g.DrawString(salt.Chars(i), New Font("Comic Sans MS", 13, FontStyle.Italic), Brushes.blue, width * (0.14 * i), height * 0.25)
g.ResetTransform()
Next
bmp.Save(path, ImageFormat.Gif)
g.Dispose()
bmp.Dispose()
g.Dispose()
bmp.Dispose()
Return salt
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim salt As String = CreateImage(Server.MapPath("~/Image/random.gif"), 30, 148)
ImgSecCodes.ImageUrl = "~/Image/random.gif"
Session.Add("salt", salt)
End If
End Sub
Public Sub SendMail(Subject As String, [To] As String, Body As String)
Dim MyMail As New SmtpClient()
Dim MyMsg As New MailMessage()
MyMail.Host = "mail.e.ir"
MyMsg.[To].Add(New MailAddress([To]))
MyMsg.Subject = Subject
MyMsg.SubjectEncoding = Encoding.UTF8
MyMsg.IsBodyHtml = True
MyMsg.From = New MailAddress("mail.e.ir", "Site:::Feedback::::mail.e.ir")
MyMsg.BodyEncoding = Encoding.UTF8
MyMsg.Body = Body
MyMail.UseDefaultCredentials = False
Dim MyCredentials As New NetworkCredential("mail.e.ir", "pass")
MyMail.Credentials = MyCredentials
MyMail.Send(MyMsg)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If TxtCodeSec.Text = Session.Item("salt") Then
Else
lbl1.Visible = True
End If
If IsValid Then
Response.Redirect( "Registration/RegFeedback.html" )
End If
Dim sr As New StreamReader(Server.MapPath("SendEmail/MailSendFeedback.htm"))
Dim Body As String = sr.ReadToEnd()
sr.Close()
Body = Body.Replace("#name#", txtName.Text)
Body = Body.Replace("#addurl#", txtAddurl.Text)
Body = Body.Replace("#email#", txtEmail.Text)
Body = Body.Replace("#gender#", ddlGender.SelectedValue)
Body = Body.Replace("#message#", txtMessage.Text)
If Page.IsValid Then
Response.Redirect( "Registration/RegFeedback.html" )
End If
SendMail("Feedback::UserSend", "mail.e.ir", Body)
End Sub
End Class
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Text
Imports System.Net
Imports System.Net.Mail
Imports System.IO
Imports System.Drawing.Text
Imports System.Drawing.Imaging
Imports System.Security.Cryptography
Imports System.Drawing
Public Partial Class _Feedback
Inherits System.Web.UI.Page
Public Function CreateSalt() As String
Dim rnd As New Random
Return rnd.Next(1000000, 9993989)
End Function
Public Function CreateImage(ByVal path As String, ByVal height As Integer, ByVal width As Integer) As String
Dim r As New Random
Dim salt As String = CreateSalt()
Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(bmp)
g.TextRenderingHint = TextRenderingHint.AntiAlias
g.Clear(Color.WhiteSmoke)
Dim mymat As New System.Drawing.Drawing2D.Matrix
Dim i As Integer
For i = 0 To Len(salt) - 1
mymat.Reset()
mymat.RotateAt(r.Next(-19, 0), New PointF(width * (0.1 * i), height * 0.25))
g.Transform = mymat
g.DrawString(salt.Chars(i), New Font("Comic Sans MS", 13, FontStyle.Italic), Brushes.blue, width * (0.14 * i), height * 0.25)
g.ResetTransform()
Next
bmp.Save(path, ImageFormat.Gif)
g.Dispose()
bmp.Dispose()
g.Dispose()
bmp.Dispose()
Return salt
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim salt As String = CreateImage(Server.MapPath("~/Image/random.gif"), 30, 148)
ImgSecCodes.ImageUrl = "~/Image/random.gif"
Session.Add("salt", salt)
End If
End Sub
Public Sub SendMail(Subject As String, [To] As String, Body As String)
Dim MyMail As New SmtpClient()
Dim MyMsg As New MailMessage()
MyMail.Host = "mail.e.ir"
MyMsg.[To].Add(New MailAddress([To]))
MyMsg.Subject = Subject
MyMsg.SubjectEncoding = Encoding.UTF8
MyMsg.IsBodyHtml = True
MyMsg.From = New MailAddress("mail.e.ir", "Site:::Feedback::::mail.e.ir")
MyMsg.BodyEncoding = Encoding.UTF8
MyMsg.Body = Body
MyMail.UseDefaultCredentials = False
Dim MyCredentials As New NetworkCredential("mail.e.ir", "pass")
MyMail.Credentials = MyCredentials
MyMail.Send(MyMsg)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If TxtCodeSec.Text = Session.Item("salt") Then
Else
lbl1.Visible = True
End If
If IsValid Then
Response.Redirect( "Registration/RegFeedback.html" )
End If
Dim sr As New StreamReader(Server.MapPath("SendEmail/MailSendFeedback.htm"))
Dim Body As String = sr.ReadToEnd()
sr.Close()
Body = Body.Replace("#name#", txtName.Text)
Body = Body.Replace("#addurl#", txtAddurl.Text)
Body = Body.Replace("#email#", txtEmail.Text)
Body = Body.Replace("#gender#", ddlGender.SelectedValue)
Body = Body.Replace("#message#", txtMessage.Text)
If Page.IsValid Then
Response.Redirect( "Registration/RegFeedback.html" )
End If
SendMail("Feedback::UserSend", "mail.e.ir", Body)
End Sub
End Class