asn2010
یک شنبه 27 مرداد 1392, 18:44 عصر
سلام به همه
اولش بگم که خوب سرچ کردم هرچند نیازی به سرچ نبود چون که قبلا این کدهارو روی هاست دیگری تست گرفته بودم و درست کار کرد ولی الان که دارم روی سرور مجازی تست میگیرم ایمیل نمیره
کارهایی که کردم
1) یک اکانت ایمیل ایجاد کردم
2) نتونستم تل (telnet) بگیرم از سرور ایمیل ولی خود پشتیبان سرور گرفتت که عکس شماره یک نشونش میده و برابر با : WIN-JUCBU44IBOB.domain.com است
عجیبه که قبلا روی هاست تل میگیرفتم بجای domain نام سایت قشنگ مینوشت حالا چرا اینجا نمی نویسه بمونه
3) کد های زیر در web.config و behind-code گذاشتم ، خطا ندارم ولی هیچی ارسال نمیشه :افسرده:
ممنون میشم کمکم کنید
web.config
<configuration>
<appSettings>
<add key="MyMailServer" value ="mail.domain.com"/>
<add key="MyMailServerPort" value ="25"/>
</appSettings>
<connectionStrings/>
<system.web>
behind-code:
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
'send message
Dim strMsg As String
strMsg = txtMessage.Text
mTo = Trim(txtTo.Text)
mFrom = Trim(txtFrom.Text)
mSubject = Trim(txtSubject.Text)
mMsg = Trim(txtMessage.Text)
mMailServer = ConfigurationManager.AppSettings.Get("MyMailServer")
mPort = ConfigurationManager.AppSettings.Get("MyMailServerPort")
mCC = Trim(txtCC.Text)
Try
Dim message As New MailMessage(mFrom, mTo, mSubject, mMsg)
If fileAttachments.HasFile Then
Dim attached As New Attachment(Trim(fileAttachments.PostedFile.FileNam e.ToString()))
message.Attachments.Add(attached)
End If
If mCC <> "" Or mCC <> String.Empty Then
Dim strCC() As String = Split(mCC, ";")
Dim strThisCC As String
For Each strThisCC In strCC
message.CC.Add(Trim(strThisCC))
Next
End If
'Dim mySmtpClient As New SmtpClient(mMailServer, mPort)
Dim mySmtpClient As New SmtpClient("WIN-JUCBU44IBOB.domain.com")
'mySmtpClient.UseDefaultCredentials = True
mySmtpClient.UseDefaultCredentials = false
mySmtpClient.Credentials = New NetworkCredential("support@dmain.com", "pass")
mySmtpClient.Send(message)
MessageBox("The mail message has been sent to " & message.To.ToString())
Catch ex As FormatException
MessageBox("Format Exception: " & ex.Message)
Catch ex As SmtpException
MessageBox("SMTP Exception: " & ex.Message)
Catch ex As Exception
MessageBox("General Exception: " & ex.Message)
End Try
End Sub
اولش بگم که خوب سرچ کردم هرچند نیازی به سرچ نبود چون که قبلا این کدهارو روی هاست دیگری تست گرفته بودم و درست کار کرد ولی الان که دارم روی سرور مجازی تست میگیرم ایمیل نمیره
کارهایی که کردم
1) یک اکانت ایمیل ایجاد کردم
2) نتونستم تل (telnet) بگیرم از سرور ایمیل ولی خود پشتیبان سرور گرفتت که عکس شماره یک نشونش میده و برابر با : WIN-JUCBU44IBOB.domain.com است
عجیبه که قبلا روی هاست تل میگیرفتم بجای domain نام سایت قشنگ مینوشت حالا چرا اینجا نمی نویسه بمونه
3) کد های زیر در web.config و behind-code گذاشتم ، خطا ندارم ولی هیچی ارسال نمیشه :افسرده:
ممنون میشم کمکم کنید
web.config
<configuration>
<appSettings>
<add key="MyMailServer" value ="mail.domain.com"/>
<add key="MyMailServerPort" value ="25"/>
</appSettings>
<connectionStrings/>
<system.web>
behind-code:
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
'send message
Dim strMsg As String
strMsg = txtMessage.Text
mTo = Trim(txtTo.Text)
mFrom = Trim(txtFrom.Text)
mSubject = Trim(txtSubject.Text)
mMsg = Trim(txtMessage.Text)
mMailServer = ConfigurationManager.AppSettings.Get("MyMailServer")
mPort = ConfigurationManager.AppSettings.Get("MyMailServerPort")
mCC = Trim(txtCC.Text)
Try
Dim message As New MailMessage(mFrom, mTo, mSubject, mMsg)
If fileAttachments.HasFile Then
Dim attached As New Attachment(Trim(fileAttachments.PostedFile.FileNam e.ToString()))
message.Attachments.Add(attached)
End If
If mCC <> "" Or mCC <> String.Empty Then
Dim strCC() As String = Split(mCC, ";")
Dim strThisCC As String
For Each strThisCC In strCC
message.CC.Add(Trim(strThisCC))
Next
End If
'Dim mySmtpClient As New SmtpClient(mMailServer, mPort)
Dim mySmtpClient As New SmtpClient("WIN-JUCBU44IBOB.domain.com")
'mySmtpClient.UseDefaultCredentials = True
mySmtpClient.UseDefaultCredentials = false
mySmtpClient.Credentials = New NetworkCredential("support@dmain.com", "pass")
mySmtpClient.Send(message)
MessageBox("The mail message has been sent to " & message.To.ToString())
Catch ex As FormatException
MessageBox("Format Exception: " & ex.Message)
Catch ex As SmtpException
MessageBox("SMTP Exception: " & ex.Message)
Catch ex As Exception
MessageBox("General Exception: " & ex.Message)
End Try
End Sub