Results 1 to 8 of 8

Thread: [RESOLVED] [2005] Email problem

  1. #1

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Resolved [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:
    1. Imports System.Web.mail
    2.  
    3. Public Class Form1
    4.  
    5.     ' Variable which will send the mail
    6.     Dim obj As System.Web.Mail.SmtpMail
    7.  
    8.     'Variable to store the attachments
    9.     Dim Attachment As System.Web.Mail.MailAttachment
    10.  
    11.     'Variable to create the message to send
    12.     Dim Mailmsg As New System.Web.Mail.MailMessage()
    13.  
    14.  
    15.     Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
    16.  
    17.         'Show open dialogue box to select the files to attach
    18.         Dim Counter As Integer
    19.         ofd.CheckFileExists = True
    20.         ofd.Title = "Select file(s) to attach"
    21.         ofd.ShowDialog()
    22.  
    23.         For Counter = 0 To UBound(ofd.FileNames)
    24.             lstAttachment.Items.Add(ofd.FileNames(Counter))
    25.         Next
    26.  
    27.     End Sub
    28.  
    29.     Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
    30.  
    31.         'Remove the attachments
    32.         If lstAttachment.SelectedIndex > -1 Then
    33.             lstAttachment.Items.RemoveAt(lstAttachment.SelectedIndex)
    34.         End If
    35.  
    36.     End Sub
    37.  
    38.     Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
    39.  
    40.         Dim Counter As Integer
    41.  
    42.         'Validate the data
    43.         If txtSMTPServer.Text = "" Then
    44.             MsgBox("Enter the SMTP server info ...!!!", MsgBoxStyle.Information, "Send Email")
    45.             Exit Sub
    46.         End If
    47.  
    48.         If txtFrom.Text = "" Then
    49.             MsgBox("Enter the From email address ...!!!", MsgBoxStyle.Information, "Send Email")
    50.             Exit Sub
    51.         End If
    52.  
    53.         If txtTo.Text = "" Then
    54.             MsgBox("Enter the Recipient email address ...!!!", MsgBoxStyle.Information, "Send Email")
    55.             Exit Sub
    56.         End If
    57.  
    58.         If txtSubject.Text = "" Then
    59.             MsgBox("Enter the Email subject ...!!!", MsgBoxStyle.Information, "Send Email")
    60.             Exit Sub
    61.         End If
    62.  
    63.         'Set the properties
    64.         'Assign the SMTP server
    65.         SmtpMail.SmtpServer = "localhost"
    66.         'Multiple recepients can be specified using ; as the delimeter
    67.         'Address of the recipient
    68.         Mailmsg.To = txtTo.Text
    69.  
    70.  
    71.         'Your From Address
    72.         'You can also use a custom header Reply-To for a different replyto address
    73.         Mailmsg.From = "\" & txtFromDisplayName.Text & "\ <" & txtFrom.Text & ">"
    74.  
    75.  
    76.         'Specify the body format
    77.         If cbFormat.Checked = True Then
    78.             Mailmsg.BodyFormat = MailFormat.Html   'Send the mail in HTML Format
    79.         Else
    80.             Mailmsg.BodyFormat = MailFormat.Text
    81.         End If
    82.  
    83.         'If you want you can add a reply to header
    84.         'Mailmsg.Headers.Add("Reply-To", "[email protected]")
    85.         'custom headersare added like this
    86.         'Mailmsg.Headers.Add("Manoj", "TestHeader")
    87.  
    88.         'Mail Subject
    89.         Mailmsg.Subject = txtSubject.Text
    90.  
    91.         'Attach the files one by one
    92.         For Counter = 0 To lstAttachment.Items.Count - 1
    93.             Attachment = New MailAttachment(lstAttachment.Items(Counter))
    94.             'Add it to the mail message
    95.             Mailmsg.Attachments.Add(Attachment)
    96.         Next
    97.  
    98.         'Mail Body
    99.         Mailmsg.Body = txtMessage.Text
    100.         'Call the send method to send the mail
    101.         SmtpMail.Send(Mailmsg)
    102.  
    103.     End Sub
    104. End Class

    Im using VB.net 2005 Express.

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  2. #2
    Junior Member
    Join Date
    Nov 2006
    Posts
    31

    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

  3. #3

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    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.

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  4. #4
    Junior Member
    Join Date
    Nov 2006
    Posts
    31

    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

  5. #5

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    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?

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  6. #6
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    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:
    1. Imports System.net.Mail
    2. Imports System.Environment
    3.  
    4.  Public Function send(ByVal strFrom As String, ByVal strSubj As String, _
    5.     ByVal strBody As String, ByVal strSendTo As String, _
    6.     Optional ByVal Attachments As String = "") As Boolean
    7.         Try
    8.  
    9.             Dim sMail As New MailMessage()
    10.  
    11.             Dim address As New MailAddress(strFrom)
    12.             Dim sendTo As New MailAddress(strSendTo)
    13.             With sMail
    14.                 .From = address
    15.                 .To.Add(sendTo)
    16.                 .Subject = strSubj
    17.                 .Body = strBody
    18.  
    19.                 Dim strFile As String
    20.                 Dim strAttach() As String = Split(Attachments, ";")
    21.                 For Each strFile In strAttach
    22.                     .Attachments.Add(New Attachment(Trim(strFile)))
    23.                 Next
    24.  
    25.             End With
    26.  
    27.             Dim strUser As String = "Your_User_Name"
    28.             Dim strPassword As String = "Your_Password"
    29.             Dim strServer As String = "Your_SMTP_Server"
    30.  
    31.             Dim smtp As SmtpClient = New SmtpClient(strServer)
    32.             If strUser <> String.Empty And strPassword <> String.Empty Then
    33.                 smtp.Credentials = New Net.NetworkCredential(strUser, strPassword)
    34.             Else
    35.                 smtp.UseDefaultCredentials = True
    36.             End If
    37.  
    38.             smtp.Send(insMail)
    39.  
    40.             sMail.Dispose()
    41.  
    42.             Return True
    43.         Catch err As Exception
    44.             MessageBox.Show("Error Sending Mail:" & NewLine & err.Message)
    45.             Return False
    46.         End Try
    47.     End Function
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  7. #7
    Junior Member
    Join Date
    Nov 2006
    Posts
    31

    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.

  8. #8

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Re: [2005] Email problem

    ah ok, thanks for the help.

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width