error of occurred EOF expected when converting c# to vb.net
Protected void btnSendPassword_Click(object sender, EventArgs e)
{
//create your variables
string strSubject = "Your Password Has Been Reset";
string strFromEmail = "me@mywebsite.com";
string strFromName = "My Website Administrator";
string strNewPassword = GeneratePassword().ToString(); //This is where you'd call the new password string.
try
{
//create the new mail message[/color]
MailMessage MailMsg = new MailMessage();
//cretate the FROM[/color]
MailMsg.From = new MailAddress(strFromEmail);
//create the subject[/color]
MailMsg.Subject = strSubject;
//We obviously need to create the TO - otherwise it goes nowhere.
MailMsg.To.Add(txtEmail.Text); //assuming there was a form to fill out and they put the right email address in.
MailMsg.IsBodyHtml = true; //I decided to make it html - so I could format the text.
MailMsg.Body = "<h1>The following email was sent to you by " + strFromName + ".</h1><br />";
MailMsg.Body += "<p>Apparently, you needed your password reset - So here it is: <br />";
MailMsg.Body += "New Password <b>" + strNewPassword + "</b><br />";
MailMsg.Body += "If you didn't request this, then - oops, you might wanna think about changing it, now. "</b>";
MailMsg.Body += "<p>Click the following link to change your password:</p>";
MailMsg.Body += "<p>http://www.mywebsite.com/passwordChangeThing/Default.aspx</P>";
//utilizing SMTP (simple mail transfer protocol)
SmtpClient smtp = new SmtpClient();
smtp.Host = "email.mywebsite.com"; //if my domain had a way of sending out emails.
smtp.Send(MailMsg); //send it
lblMessage.Text = "Message Sent Successfully"; //tell the person that the email was sent.
}
catch (Exception ex)
{
lblMessage.Text = "Error: " + ex.ToString(); //or tell the person that they screwed up and it's all their fault.... or what the actual error was.
}
}
MailMsg.Body +="If you didn't request this, then - oops, you might wanna
think about changing it, now." +
"</b>";
Refer Below Converted Code :
Protected Sub btnSendPassword_Click(sender As Object, e As EventArgs)
'create your variables
Dim strSubject As String = "Your Password Has Been Reset"
Dim strFromEmail As String = "me@mywebsite.com"
Dim strFromName As String = "My Website Administrator"
Dim strNewPassword As String = GeneratePassword().ToString()
'This is where you'd call the new password string.
Try
'create the new mail message[/color]
Dim MailMsg As New MailMessage()
'cretate the FROM[/color]
MailMsg.From = New MailAddress(strFromEmail)
'create the subject[/color]
MailMsg.Subject = strSubject
'We obviously need to create the TO - otherwise it goes nowhere.
MailMsg.[To].Add(txtEmail.Text)
'assuming there was a form to fill out and they put the right email address in.
MailMsg.IsBodyHtml = True
'I decided to make it html - so I could format the text.
MailMsg.Body = "<h1>The following email was sent to you by " + strFromName + ".</h1><br />"
MailMsg.Body += "<p>Apparently, you needed your password reset - So here it is: <br />"
MailMsg.Body += "New Password <b>" + strNewPassword + "</b><br />"
MailMsg.Body += "If you didn't request this, then - oops, you might wanna think about changing it, now." + "</b>"
MailMsg.Body += "<p>Click the following link to change your password:</p>"
MailMsg.Body += "<p>http://www.mywebsite.com/passwordChangeThing/Default.aspx</P>"
'utilizing SMTP (simple mail transfer protocol)
Dim smtp As New SmtpClient()
smtp.Host = "email.mywebsite.com"
'if my domain had a way of sending out emails.
smtp.Send(MailMsg)
'send it
'tell the person that the email was sent.
lblMessage.Text = "Message Sent Successfully"
Catch ex As Exception
'or tell the person that they screwed up and it's all their fault.... or what the actual error was.
lblMessage.Text = "Error: " + ex.ToString()
End Try
End Sub
Thanks,
Karthick S
Marked as answer by Qi Wu - MSFT on Jan 31, 2012 01:21 AM
Protected Sub btnSendPassword_Click(ByVal sender As Object, ByVal e As EventArgs)
'create your variables
Dim strSubject As String = "Your Password Has Been Reset"
Dim strFromEmail As String = "me@mywebsite.com"
Dim strFromName As String = "My Website Administrator"
Dim strNewPassword As String = GeneratePassword().ToString() 'This is where you'd call the new password string.
Try
'create the new mail message[/color]
Dim MailMsg As MailMessage = New MailMessage()
'cretate the FROM[/color]
MailMsg.From = New MailAddress(strFromEmail)
'create the subject[/color]
MailMsg.Subject = strSubject
'We obviously need to create the TO - otherwise it goes nowhere.
Dim 'assuming there was a form to fill out and they put the right email address in. As MailMsg.To.Add(txtEmail.Text)
MailMsg.IsBodyHtml = True 'I decided to make it html - so I could format the text.
MailMsg.Body = "<h1>The following email was sent to you by " + strFromName + ".</h1><br />"
MailMsg.Body += "<p>Apparently, you needed your password reset - So here it is: <br />"
MailMsg.Body += "New Password <b>" + strNewPassword + "</b><br />"
MailMsg.Body += "If you didn't request this, then - oops, you might wanna think about changing it, now. </b>"
MailMsg.Body += "<p>Click the following link to change your password:</p>"
MailMsg.Body += "<p>http://www.mywebsite.com/passwordChangeThing/Default.aspx</P>"
'utilizing SMTP (simple mail transfer protocol)
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = "email.mywebsite.com" 'if my domain had a way of sending out emails.
Dim 'send it As smtp.Send(MailMsg)
lblMessage.Text = "Message Sent Successfully" 'tell the person that the email was sent.
Catch ex As Exception
lblMessage.Text = "Error: " + ex.ToString() 'or tell the person that they screwed up and it's all their fault.... or what the actual error was.
End Try
End Sub
Protected Sub btnSendPassword_Click(sender As Object, e As EventArgs)
'create your variables
Dim strSubject As String = "Your Password Has Been Reset"
Dim strFromEmail As String = "me@mywebsite.com"
Dim strFromName As String = "My Website Administrator"
Dim strNewPassword As String = GeneratePassword().ToString()
'This is where you'd call the new password string.
Try
'create the new mail message[/color]
Dim MailMsg As New MailMessage()
'cretate the FROM[/color]
MailMsg.From = New MailAddress(strFromEmail)
'create the subject[/color]
MailMsg.Subject = strSubject
'We obviously need to create the TO - otherwise it goes nowhere.
MailMsg.[To].Add(txtEmail.Text)
'assuming there was a form to fill out and they put the right email address in.
MailMsg.IsBodyHtml = True
'I decided to make it html - so I could format the text.
MailMsg.Body = "<h1>The following email was sent to you by " & strFromName & ".</h1><br />"
MailMsg.Body += "<p>Apparently, you needed your password reset - So here it is: <br />"
MailMsg.Body += "New Password <b>" & strNewPassword & "</b><br />"
MailMsg.Body += "If you didn't request this, then - oops, you might wanna think about changing it, now.</b>"
MailMsg.Body += "<p>Click the following link to change your password:</p>"
MailMsg.Body += "<p>http://www.mywebsite.com/passwordChangeThing/Default.aspx</P>"
'utilizing SMTP (simple mail transfer protocol)
Dim smtp As New SmtpClient()
smtp.Host = "email.mywebsite.com"
'if my domain had a way of sending out emails.
smtp.Send(MailMsg)
'send it
'tell the person that the email was sent.
lblMessage.Text = "Message Sent Successfully"
Catch ex As Exception
'or tell the person that they screwed up and it's all their fault.... or what the actual error was.
lblMessage.Text = "Error: " & ex.ToString()
End Try
End Sub
Please Mark as Answer if the post helps you.
My BLOG
queenDevil
Member
12 Points
14 Posts
help in converting C# to VB.net
Jan 17, 2012 03:55 AM|LINK
error of occurred EOF expected when converting c# to vb.net
Protected void btnSendPassword_Click(object sender, EventArgs e) { //create your variables string strSubject = "Your Password Has Been Reset"; string strFromEmail = "me@mywebsite.com"; string strFromName = "My Website Administrator"; string strNewPassword = GeneratePassword().ToString(); //This is where you'd call the new password string. try { //create the new mail message[/color] MailMessage MailMsg = new MailMessage(); //cretate the FROM[/color] MailMsg.From = new MailAddress(strFromEmail); //create the subject[/color] MailMsg.Subject = strSubject; //We obviously need to create the TO - otherwise it goes nowhere. MailMsg.To.Add(txtEmail.Text); //assuming there was a form to fill out and they put the right email address in. MailMsg.IsBodyHtml = true; //I decided to make it html - so I could format the text. MailMsg.Body = "<h1>The following email was sent to you by " + strFromName + ".</h1><br />"; MailMsg.Body += "<p>Apparently, you needed your password reset - So here it is: <br />"; MailMsg.Body += "New Password <b>" + strNewPassword + "</b><br />"; MailMsg.Body += "If you didn't request this, then - oops, you might wanna think about changing it, now. "</b>"; MailMsg.Body += "<p>Click the following link to change your password:</p>"; MailMsg.Body += "<p>http://www.mywebsite.com/passwordChangeThing/Default.aspx</P>"; //utilizing SMTP (simple mail transfer protocol) SmtpClient smtp = new SmtpClient(); smtp.Host = "email.mywebsite.com"; //if my domain had a way of sending out emails. smtp.Send(MailMsg); //send it lblMessage.Text = "Message Sent Successfully"; //tell the person that the email was sent. } catch (Exception ex) { lblMessage.Text = "Error: " + ex.ToString(); //or tell the person that they screwed up and it's all their fault.... or what the actual error was. } }ignatandrei
All-Star
135122 Points
21676 Posts
Moderator
MVP
Re: help in converting C# to VB.net
Jan 17, 2012 04:06 AM|LINK
This is C#
What is the VB.NET version?
karthicks
All-Star
31382 Points
5424 Posts
Re: help in converting C# to VB.net
Jan 17, 2012 04:08 AM|LINK
you have missed out + operator in below line
MailMsg.Body +="If you didn't request this, then - oops, you might wanna think about changing it, now." + "</b>";
Refer Below Converted Code :
Karthick S
dineshchaudh...
Member
326 Points
131 Posts
Re: help in converting C# to VB.net
Jan 17, 2012 04:10 AM|LINK
http://www.developerfusion.com/tools/convert/vb-to-csharp/
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
prasadP
Contributor
5266 Points
771 Posts
Re: help in converting C# to VB.net
Jan 17, 2012 04:11 AM|LINK
Protected Sub btnSendPassword_Click(ByVal sender As Object, ByVal e As EventArgs) 'create your variables Dim strSubject As String = "Your Password Has Been Reset" Dim strFromEmail As String = "me@mywebsite.com" Dim strFromName As String = "My Website Administrator" Dim strNewPassword As String = GeneratePassword().ToString() 'This is where you'd call the new password string. Try 'create the new mail message[/color] Dim MailMsg As MailMessage = New MailMessage() 'cretate the FROM[/color] MailMsg.From = New MailAddress(strFromEmail) 'create the subject[/color] MailMsg.Subject = strSubject 'We obviously need to create the TO - otherwise it goes nowhere. Dim 'assuming there was a form to fill out and they put the right email address in. As MailMsg.To.Add(txtEmail.Text) MailMsg.IsBodyHtml = True 'I decided to make it html - so I could format the text. MailMsg.Body = "<h1>The following email was sent to you by " + strFromName + ".</h1><br />" MailMsg.Body += "<p>Apparently, you needed your password reset - So here it is: <br />" MailMsg.Body += "New Password <b>" + strNewPassword + "</b><br />" MailMsg.Body += "If you didn't request this, then - oops, you might wanna think about changing it, now. </b>" MailMsg.Body += "<p>Click the following link to change your password:</p>" MailMsg.Body += "<p>http://www.mywebsite.com/passwordChangeThing/Default.aspx</P>" 'utilizing SMTP (simple mail transfer protocol) Dim smtp As SmtpClient = New SmtpClient() smtp.Host = "email.mywebsite.com" 'if my domain had a way of sending out emails. Dim 'send it As smtp.Send(MailMsg) lblMessage.Text = "Message Sent Successfully" 'tell the person that the email was sent. Catch ex As Exception lblMessage.Text = "Error: " + ex.ToString() 'or tell the person that they screwed up and it's all their fault.... or what the actual error was. End Try End SubBlog
iGulfam
Contributor
4794 Points
947 Posts
Re: help in converting C# to VB.net
Jan 17, 2012 04:14 AM|LINK
My BLOG
jennyortem
Member
306 Points
97 Posts
Re: help in converting C# to VB.net
Jan 17, 2012 04:32 AM|LINK
Hello,
Try the link below.
http://www.developerfusion.com/tools/convert/csharp-to-vb/
David Anton
Contributor
3704 Points
638 Posts
Re: help in converting C# to VB.net
Jan 17, 2012 02:45 PM|LINK
Karthick is right - the code is not valid C# code.
Converters must assume that the code being converted conforms to the proper language syntax. If not, then the result will be unpredictable.
Once you change the code to be proper C# code, then any converter will convert this sample.
http://www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
saftrazink
Member
282 Points
74 Posts
Re: help in converting C# to VB.net
Jan 26, 2012 06:07 PM|LINK
next time, you can use the code convertors one line at a time, or only conver a bunch of lines at a time,
so you can know where exactly is the error,
you can also add the code to the visual studio, and see if it produces a syntax error or not
hirendra_sis...
Member
2 Points
1 Post
Re: help in converting C# to VB.net
Jan 23, 2013 04:28 PM|LINK
Also try this online free converter:
defercode converter
it gives the good results.
thanks