The specified string is not in the form required for an e-mail address !!!!!!!! URGENT

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi all,
1st of all thx for viewing this topic
i am read the email address from the notepad using :
Dim abc As String = My.Computer.FileSystem.ReadAllText(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.txt"))<br/>
Dim pqr As String() = abc.Split(vbNewLine)

after that i assign the value to email.from.
In debug mode, i traced and found the value assign in to mail.from is an valid email.. but ! the error still come out <br/>

any of you face this prob before ? <br/>

Thanks all ^^
this is my code :

Dim abc As String = My.Computer.FileSystem.ReadAllText(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.txt"))<br/>
Dim pqr As String() = abc.Split(vbNewLine)<br/>
Label1.Text = pqr(0).ToString<br/>
Label2.Text = pqr(1).ToString<br/>
Label3.Text = pqr(2).ToString<br/>
Label4.Text = pqr(3).ToString<br/>
Label5.Text = pqr(4).ToString<br/>
Label6.Text = pqr(5).ToString<br/>
Label7.Text = pqr(6).ToString<br/>
Dim filenames() As String = Directory.GetFiles(Label1.Text)<br/>
Dim i As Integer = 0<br/>
<br/>
Dim filename As String<br/>
Dim fileconvert As Double<br/>
Dim filesize As String<br/>
Dim Mdate As String<br/>
Dim allfiles As New ArrayList<br/>
Dim eachfile As String<br/>
READ ALL FILES <br/>
For i = 0 To filenames.Length - 1<br/>
GET FILE NAME<br/>
filename = Path.GetFileName(filenames(i))<br/>
fileconvert = (Round(CDbl(FileLen(Label1.Text + "" + filename) / 1024))) + 1<br/>
filesize = fileconvert.ToString<br/>
Mdate = CStr(CDate(IO.File.GetLastWriteTime(filenames(i))).Date)<br/>
allfiles.Add(Mdate + vbTab + vbTab + filename + vbTab + vbTab + filesize + "kb")<br/>
Next i<br/>
allfiles.Sort()<br/>
allfiles.ToArray()<br/>
allfiles.Reverse()<br/>
Dim filelist As String = ""<br/>
For Each eachfile In allfiles<br/>
filelist += eachfile + vbNewLine<br/>
Next<br/>
<br/>
Dim SPath() As String<br/>
Dim FolderName As String<br/>
Dim YtdDate As Date<br/>
SPath = Label1.Text.Split("")<br/>
<br/>
FolderName = SPath(SPath.Length - 1)<br/>
YtdDate = DateAdd(DateInterval.Day, -1, System.DateTime.Now.Date)<br/>
<br/>
<br/>
Try<br/>
Dim SmtpServer As New SmtpClient()<br/>
Dim mail As New MailMessage()<br/>
USER NAME & PASSWORD<br/>
SmtpServer.Credentials = New Net.NetworkCredential(Label2.Text, Label3.Text)<br/>
PORT<br/>
SmtpServer.Port = Label4.Text<br/>
HOST<br/>
SmtpServer.Host = Label5.Text<br/>
mail = New MailMessage()<br/>
FROM<br/>
<br/>
mail.From = New MailAddress(Label6.Text)<br/>
<br/>
TO <br/>
mail.To.Add(Label7.Text)<br/>
<br/>
SUBJECT<br/>
mail.Subject = (" Backup List Server: " + FolderName + " Date: " + YtdDate)<br/>
<br/>
BODY<br/>
mail.Body = "Hi," + vbNewLine + vbNewLine + "This Backup folder consist of " + (filenames.Length - 1).ToString + " Files" + vbNewLine + "Please refer the file list here:" + vbNewLine + vbNewLine + "Modified Date" +
vbTab + vbTab + "File Name" + vbTab + vbTab + "File Size" + vbNewLine + filelist + vbNewLine + "Thanks"<br/>
<br/>
TIME OUT = 10s<br/>
SmtpServer.Timeout = 10000<br/>
<br/>
SENT<br/>
SmtpServer.Send(mail)<br/>
Catch ex As Exception<br/>
Finally<br/>
End Try



View the full article
 
Back
Top