Hmmm, if error message is on sending, then try SMTP port 465
Its not on sending it just says that the string is not recognized as a valid email address the label works right, and the email downloads fine so
Ik i bumped its just ive had midterms last week so i couldnt really get on
Originally Posted by Bombsaway707
Its not on sending it just says that the string is not recognized as a valid email address the label works right, and the email downloads fine so
Ik i bumped its just ive had midterms last week so i couldnt really get on
Then you just need to look for invalid characters and remove them. Did you tried Trim Method ? Also, you sure the Target file has only 1 email address :P
Code:
Private Sub Emaillocation()
Dim Target As String
Target = "http:/**********/*****/Target.txt"
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(Target)
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("windows-1252"))
Dim Targettxt As String
Targettxt = sr.ReadToEnd()
TargetX.Text = Targettxt
Call email()
End Sub
Private Sub email()
Dim AnEmailMessage As New MailMessage
AnEmailMessage.From = New MailAddress("************@gmail.com")
Dim mailTo As String = TagetX.Text
AnEmailMessage.To.Add(mailTo)
AnEmailMessage.Subject = ("**************")
AnEmailMessage.Body = ("*****************************")
Dim SimpleSMTP As New SmtpClient("smtp.gmail.com")
SimpleSMTP.Port = 587
SimpleSMTP.EnableSsl = True
SimpleSMTP.Credentials = New System.Net.NetworkCredential("**************@gmail.com", "******")
SimpleSMTP.Send(AnEmailMessage)
End Sub
What we really need you to do is put a breakpoint on the highlighted line, then when the program breaks there, hover your mouse over the "mailTo" variable and check it's value.
Otherwise, you can try this (very general Regex, could not be fucked trying to type out a more specific one because you're already working with an email address, you just need to make sure it's correct. You will need to import the System.Text.RegularExpressions namespace for this to work.)
[php]
Dim NewReg As New Regex("\b.*?@.*\b")
If NewReg.IsMatch(targetX.Text) Then
AnEmailMessage.To.Add(NewReg.Match(targetX.Text).V alue)
Else
MessageBox.Show(String.Concat("There was an invalid email address found!", New String(ControlChars.CrLf, 2), targetX.Text) , "Error: Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
[/php]
Originally Posted by Hassan
Then you just need to look for invalid characters and remove them. Did you tried Trim Method ? Also, you sure the Target file has only 1 email address :P
Yep im only sending it to 1 email address
Originally Posted by Jason
Code:
Private Sub Emaillocation()
Dim Target As String
Target = "http:/**********/*****/Target.txt"
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(Target)
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("windows-1252"))
Dim Targettxt As String
Targettxt = sr.ReadToEnd()
TargetX.Text = Targettxt
Call email()
End Sub
Private Sub email()
Dim AnEmailMessage As New MailMessage
AnEmailMessage.From = New MailAddress("************@gmail.com")
Dim mailTo As String = TagetX.Text
AnEmailMessage.To.Add(mailTo)
AnEmailMessage.Subject = ("**************")
AnEmailMessage.Body = ("*****************************")
Dim SimpleSMTP As New SmtpClient("smtp.gmail.com")
SimpleSMTP.Port = 587
SimpleSMTP.EnableSsl = True
SimpleSMTP.Credentials = New System.Net.NetworkCredential("**************@gmail.com", "******")
SimpleSMTP.Send(AnEmailMessage)
End Sub
What we really need you to do is put a breakpoint on the highlighted line, then when the program breaks there, hover your mouse over the "mailTo" variable and check it's value.
Otherwise, you can try this (very general Regex, could not be fucked trying to type out a more specific one because you're already working with an email address, you just need to make sure it's correct. You will need to import the System.Text.RegularExpressions namespace for this to work.)
[php]
Dim NewReg As New Regex("\b.*?@.*\b")
If NewReg.IsMatch(targetX.Text) Then
AnEmailMessage.To.Add(NewReg.Match(targetX.Text).V alue)
Else
MessageBox.Show(String.Concat("There was an invalid email address found!", New String(ControlChars.CrLf, 2), targetX.Text) , "Error: Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
[/php]
Thanks, ill try this once i get free time to work on my program