PDA

View Full Version : سوال: برای ارسال میل مشکل دارم



attaee
یک شنبه 14 اسفند 1390, 14: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

attaee
دوشنبه 15 اسفند 1390, 18:44 عصر
کسی نیست کمک کنه؟؟؟؟؟

reza69
دوشنبه 15 اسفند 1390, 22:39 عصر
دوست من این همه کد برای ارسال ایمیله؟:متعجب: حالا می خوای به yahoo بفرستی یا gmail ؟
من این کد ها رو برای ارسال به gmail دارم ولی با یا هو هیچوقت نمیشه بفرستی. من خودم چند روز پیش تو نخ ارسال به yahoo بودم ولی کاری از پیش نبردم ولی به gmail میشه بفرستی.

Imports System.Net.Mail
Public Class SendEmail
Public Shared Sub SendMessage(ByVal subject As String, ByVal messageBody As String, _
ByVal fromAddress As String, ByVal toAddress As String, ByVal ccAddress As String)
Dim message As New MailMessage()
Dim client As New SmtpClient()
'Set the sender's address
message.From = New MailAddress(fromAddress)
'Allow multiple "To" addresses to be separated by a semi-colon
If (toAddress.Trim.Length > 0) Then
For Each addr As String In toAddress.Split(";"c)
message.To.Add(New MailAddress(addr))
Next
End If
'Allow multiple "Cc" addresses to be separated by a semi-colon
If (ccAddress.Trim.Length > 0) Then
For Each addr As String In ccAddress.Split(";"c)
message.CC.Add(New MailAddress(addr))
Next
End If
'Set the subject and message body text
message.Subject = subject
message.Body = messageBody
'TODO: *** Modify for your SMTP server ***
'Set the SMTP server to be used to send the message
client.Host = "YourMailServer"
'Send the e-mail message
client.Send(message)
End Sub
End Class

arash020
سه شنبه 16 اسفند 1390, 11:25 صبح
http://eaglevb.blogfa.com/

نمونه برنامه application