|
-
Nov 14th, 2006, 02:04 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Email problem
Thought i had every thing fixed but i guess not.
Im using Advance SMTP Server for send my email to the Recipient, the program says it was sent successfully and i check my email box 10mins later and it isnt there? here is a link to Advance SMTP Server.
http://www.softstack.com/advsmtp.html
and here is my code that im using.
VB Code:
Imports System.Web.mail
Public Class Form1
' Variable which will send the mail
Dim obj As System.Web.Mail.SmtpMail
'Variable to store the attachments
Dim Attachment As System.Web.Mail.MailAttachment
'Variable to create the message to send
Dim Mailmsg As New System.Web.Mail.MailMessage()
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
'Show open dialogue box to select the files to attach
Dim Counter As Integer
ofd.CheckFileExists = True
ofd.Title = "Select file(s) to attach"
ofd.ShowDialog()
For Counter = 0 To UBound(ofd.FileNames)
lstAttachment.Items.Add(ofd.FileNames(Counter))
Next
End Sub
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
'Remove the attachments
If lstAttachment.SelectedIndex > -1 Then
lstAttachment.Items.RemoveAt(lstAttachment.SelectedIndex)
End If
End Sub
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim Counter As Integer
'Validate the data
If txtSMTPServer.Text = "" Then
MsgBox("Enter the SMTP server info ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
If txtFrom.Text = "" Then
MsgBox("Enter the From email address ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
If txtTo.Text = "" Then
MsgBox("Enter the Recipient email address ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
If txtSubject.Text = "" Then
MsgBox("Enter the Email subject ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
'Set the properties
'Assign the SMTP server
SmtpMail.SmtpServer = "localhost"
'Multiple recepients can be specified using ; as the delimeter
'Address of the recipient
Mailmsg.To = txtTo.Text
'Your From Address
'You can also use a custom header Reply-To for a different replyto address
Mailmsg.From = "\" & txtFromDisplayName.Text & "\ <" & txtFrom.Text & ">"
'Specify the body format
If cbFormat.Checked = True Then
Mailmsg.BodyFormat = MailFormat.Html 'Send the mail in HTML Format
Else
Mailmsg.BodyFormat = MailFormat.Text
End If
'If you want you can add a reply to header
'custom headersare added like this
'Mailmsg.Headers.Add("Manoj", "TestHeader")
'Mail Subject
Mailmsg.Subject = txtSubject.Text
'Attach the files one by one
For Counter = 0 To lstAttachment.Items.Count - 1
Attachment = New MailAttachment(lstAttachment.Items(Counter))
'Add it to the mail message
Mailmsg.Attachments.Add(Attachment)
Next
'Mail Body
Mailmsg.Body = txtMessage.Text
'Call the send method to send the mail
SmtpMail.Send(Mailmsg)
End Sub
End Class
Im using VB.net 2005 Express.
-
Nov 14th, 2006, 06:06 PM
#2
Junior Member
Re: [2005] Email problem
I'd definitely check on the configuration of your SMTP server. I created a simple form, and imported your code, other than the fact that you are using 'System.Web.Mail' which has been obsoleted in .NET framework v2.0, everything in your code functions as you'd expect it to.
It could be that your SMTP server is accepting the message but not forwarding it on due to some configuration issue.
Hope this helps,
Brian Swanson
-
Nov 14th, 2006, 08:52 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] Email problem
I followed there help page and i did every thing they said, i set my SMTP part of my app to localhost as they told me to do and it still dosent get sent to my email nor my friends. do you think its because im using a hotmail account?? I tested to see if my isp blocks port 25 with the SMTP server app and it says its not blocked from sending emails. there must be sumtin im missing.
-
Nov 15th, 2006, 09:31 AM
#4
Junior Member
Re: [2005] Email problem
Who are you trying to send too? Many major ISPs are starting to implement functionality that keeps their users from receiving an email from an email address unless the email is coming from a listed server for the sending emailer's domain...
ex:
Your email address: [email protected]
My email address: [email protected]
when you use your code as you've got it shown, the email will be from [email protected], so gmail would actually check to see if the ip address the email is being sent from is registered with hotmail.com, and reject it because it's not.
Just a thought...
I'd check with whoever is actually providing you your internet access, and see what their SMTP server is, and use it. But of course, you'd have to use an email address from their domain as well. It'll at the very minimum let you know where the problem might exist.
Hope this helps,
Brian Swanson
-
Nov 15th, 2006, 10:06 PM
#5
Thread Starter
Hyperactive Member
Re: [2005] Email problem
Hmmm. I'll take a look at what SMTP my ISP is using. Just a quick question, what would hotmails SMTP be? i think yahoos is smtp.mail.yahoo.com, what what would hotmails be?
-
Nov 15th, 2006, 10:59 PM
#6
Re: [2005] Email problem
In VB 2005 the System.Web.Mail Namespace has been replaced by the System.Net.Mail Namespace for starters.
Also you have your smtp server set as localhost. Is your machine running an SMTP server?
This is an example of a sendmail function that I use.
VB Code:
Imports System.net.Mail
Imports System.Environment
Public Function send(ByVal strFrom As String, ByVal strSubj As String, _
ByVal strBody As String, ByVal strSendTo As String, _
Optional ByVal Attachments As String = "") As Boolean
Try
Dim sMail As New MailMessage()
Dim address As New MailAddress(strFrom)
Dim sendTo As New MailAddress(strSendTo)
With sMail
.From = address
.To.Add(sendTo)
.Subject = strSubj
.Body = strBody
Dim strFile As String
Dim strAttach() As String = Split(Attachments, ";")
For Each strFile In strAttach
.Attachments.Add(New Attachment(Trim(strFile)))
Next
End With
Dim strUser As String = "Your_User_Name"
Dim strPassword As String = "Your_Password"
Dim strServer As String = "Your_SMTP_Server"
Dim smtp As SmtpClient = New SmtpClient(strServer)
If strUser <> String.Empty And strPassword <> String.Empty Then
smtp.Credentials = New Net.NetworkCredential(strUser, strPassword)
Else
smtp.UseDefaultCredentials = True
End If
smtp.Send(insMail)
sMail.Dispose()
Return True
Catch err As Exception
MessageBox.Show("Error Sending Mail:" & NewLine & err.Message)
Return False
End Try
End Function
-
Nov 16th, 2006, 10:16 AM
#7
Junior Member
Re: [2005] Email problem
As far as I know Hotmail doesn't have a public SMTP server. You have to use WebDAV or their web interface for sending/receiving emails.
-
Nov 18th, 2006, 02:18 AM
#8
Thread Starter
Hyperactive Member
Re: [2005] Email problem
ah ok, thanks for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|