[Help]Wierd error message

Posts 115 of 19 · Page 1 of 2
[Help]Wierd error message
Ok so to simplify this and make it hopefully easy to answer, i need to send an email via a program to a certain email adress, i need to be able to change it remotely so on my server i have a .txt file which contains the email i want to send the email too. But when i run my program it says "this string is not a valid" or something. I checked to make sure it dl's the right text file and it does and the email sender works if u put in ur own location but it doesnt like using the external .txt file for some reason...
any help?
Could we see the exact error message?
What part isn't working now, I didn't get it o_O.

[php]Dim wc as new net.webclient

Dim email as string = wc.downloadstring(url)

msgbox(email)
[/php]
proper result?
let me see your source and error please
Well, without any actual code provided, there's not a lot of things we can suggest. The most likely problem is that you're incorrectly downloading the string. Post your download method here so we can see if that's the problem, or PM me.
Send the code to jason, he is more helpful then cosconub. I vouch you send to jason. No offense cosconub
Ok heres the source code:
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")
        AnEmailMessage.To.Add(TargetX.Text) 'ERROR HERE
        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

The error occurs when sending the email, i can get the entire error if need be but im very tired right now and am going to bed, will check in morning
* = hidden for safety reasons
Have you tried putting a breakpoint at that line and checking what value "targetX.Text" holds?

Also, try changing which encoding you use when downloading. UTF8 is a pretty common one.
Quote Originally Posted by Jason View Post
Have you tried putting a breakpoint at that line and checking what value "targetX.Text" holds?

Also, try changing which encoding you use when downloading. UTF8 is a pretty common one.
Using UTF8 encoding shouldn't really do anything if the page only contains one email address or so...
Quote Originally Posted by Blubb1337 View Post
Using UTF8 encoding shouldn't really do anything if the page only contains one email address or so...
Im not concerned about UTF8 solving his problems, it's just I'm not too savvy with:

Code:
System.Text.Encoding.GetEncoding("windows-1252")
It probably isn't the problem, but using a predefined encoding set would make things a bit more controlled til the error IS found.
1st there's no point of redefining encoding unless you know what exactly the encoding is used, plus I don't think there's a problem with encoding.

I think there's some null character or something like whitespaces in the Target file. Happened to my once. Try trimming it manually or via VB:

[php]Sub Emaillocation()
Dim Target As String
Target = "http:/**********/*****/Target.txt"
Dim wc as new net.webclient
Dim ID as string = wc.downloadstring(Target)
ID = ID.Trim
TargetX.Text = ID
End Sub[/php]Try it.
Make a label, visible = false, make the text of the label remote (heres a link) then just set the email to label1.Text


(Change the .txt online to the email that you want it to send it.)


As simple as that, it would take 15 mins MAX
Quote Originally Posted by Web-Designer View Post
Make a label, visible = false, make the text of the label remote (heres a link) then just set the email to label1.Text


(Change the .txt online to the email that you want it to send it.)


As simple as that, it would take 15 mins MAX
Ever heard about variables? Lol.
did you inport net?

and btw oO that really hurt me deep man,
Hmmm, if error message is on sending, then try SMTP port 465
Posts 115 of 19 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

None

Need help?