-
Aug 12th, 2011, 05:21 PM
#1
Thread Starter
Junior Member
[RESOLVED] Trying to send an email. Getting Error Message. Please Help!
I got my last problem to work but now i have a new one. My program works great on my computer(where i made it) but every other computer i try to open it on it gives an error message. the program doesnt even come up just the error msg. Ive tried it on 2 computers that both have .net with no luck.
Script(although I think it is working fine):
Code:
Imports System.Net.Mail
Public Class Form1
Dim y As Integer
Dim x As Integer
Dim z As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text.ToLower.Contains("@hotmail") Or TextBox1.Text.ToLower.Contains("@live") Or TextBox1.Text.ToLower.Contains("@msn") Then
x = 4
ElseIf TextBox1.Text.ToLower.Contains("@gmail") Then
x = 2
y = 2
z = 1
ElseIf TextBox1.Text.ToLower.Contains("@aol") Then
x = 2
y = 3
z = 1
ElseIf TextBox1.Text.ToLower.Contains("@yahoo") Then
x = 5
End If
'-----------------------------------------------------------------------------------------------------------------
'This is for Yahoo
If x = 5 Then
start1:
Dim oSmtp As New EASendMailObjLib.Mail
Form2.Label2.Text = Val(Form2.Label2.Text) + 1
oSmtp.LicenseCode = "TryIt"
oSmtp.FromAddr = TextBox1.Text
oSmtp.AddRecipientEx(TextBox3.Text, 0)
oSmtp.Subject = TextBox5.Text
oSmtp.BodyText = RichTextBox1.Text
oSmtp.ServerAddr = "smtp.mail.yahoo.com"
oSmtp.UserName = TextBox1.Text
oSmtp.Password = TextBox2.Text
oSmtp.ServerPort = 465
oSmtp.SSL_init()
If oSmtp.AddAttachment(TextBox6.Text) <> 0 Then
End If
If oSmtp.SendMail() = 0 Then
Form2.Show()
Else
MsgBox("ERROR" & oSmtp.GetLastErrDescription())
End If
'-----------------------------------------------------------------------------------------------------------------------------
'Multiple
If RadioButton1.Checked Then GoTo start1
ElseIf z = 1 Then
start2:
Dim oSmtp As New EASendMailObjLib.Mail
'--------------------------------------------------------------------------------------------------------------------
'This is for AOL and Gmail
Dim smtpServer As New SmtpClient
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential(TextBox4.Text, TextBox2.Text)
Form2.Label2.Text = Val(Form2.Label2.Text) + 1
If x = 1 Then smtpServer.Port = 465
If x = 2 Then smtpServer.Port = 587
If x = 3 Then smtpServer.Port = 995
If y = 1 Then smtpServer.Host = "smtp.live.com"
If y = 2 Then smtpServer.Host = "smtp.gmail.com"
If y = 3 Then smtpServer.Host = "smtp.aol.com"
If y = 4 Then smtpServer.Host = "smtp.mail.yahoo.com"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress(TextBox1.Text)
mail.To.Add(TextBox3.Text)
mail.Subject = TextBox5.Text
mail.Body = RichTextBox1.Text
If TextBox6.Text.Contains(Text) Then mail.Attachments.Add(New Attachment(TextBox6.Text, "Text/plain"))
smtpServer.Send(mail)
If RadioButton1.Checked = False or true Then Form2.Show()
'-----------------------------------------------------------------------------------------------------------------------------
'Multiple
If RadioButton1.Checked Then GoTo start2
'-----------------------------------------------------------------------------------------------------------------------
'This is for HotMail, Live, or MSN
ElseIf x = 4 Then
start3:
Dim oSmtp As New EASendMailObjLib.Mail
Form2.Label2.Text = Val(Form2.Label2.Text) + 1
oSmtp.LicenseCode = "TryIt"
oSmtp.FromAddr = TextBox1.Text
oSmtp.AddRecipientEx(TextBox3.Text, 0)
oSmtp.Subject = TextBox5.Text
oSmtp.BodyText = RichTextBox1.Text
oSmtp.ServerAddr = "smtp.live.com"
oSmtp.UserName = TextBox1.Text
oSmtp.Password = TextBox2.Text
oSmtp.ServerPort = 587
oSmtp.SSL_init()
If oSmtp.AddAttachment(TextBox6.Text) <> 0 Then
End If
If oSmtp.SendMail() = 0 Then
Form2.Show()
Else
MsgBox("ERROR" & oSmtp.GetLastErrDescription())
End If
End If
'-----------------------------------------------------------------------------------------------------------------------------
'Multiple
If RadioButton1.Checked Then GoTo start3
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim OpenDLG As New OpenFileDialog
OpenDLG.Title = "Open File"
OpenDLG.InitialDirectory = "C:\Documents and Settings\My Documents\"
OpenDLG.RestoreDirectory = True
DialogResult = OpenDLG.ShowDialog
If DialogResult = Windows.Forms.DialogResult.OK Then
Dim objreader As New System.IO.StreamReader(OpenDLG.FileName)
TextBox6.Text = objreader.ReadToEnd
objreader.Close()
TextBox6.Text = OpenDLG.FileName.ToString()
ElseIf DialogResult = Windows.Forms.DialogResult.Cancel Then
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox("You Have Stopped Sending")
Me.Close()
End Sub
End Class
The error says "sorry but the program has incountered an error and has to close" and it wants me to send an error report to microsoft.
Last edited by jackjackkiwi; Aug 16th, 2011 at 10:29 PM.
Reason: Privacy
-
Aug 15th, 2011, 08:41 AM
#2
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
-
Aug 15th, 2011, 08:56 AM
#3
Re: Trying to send an email. Getting Error Message. Please Help!
Please edit your original question as follows, wrap all code in code tags via the editors button marked code as it is difficult to read code as posted. Next explain where the code is experiencing issues, if you are not sure then wrap the code with Try/Catch statements and in the catch portion of the Try/Catch write the error to a text file then report back here which line caused the problem along with the exact error message.
In the section marked “this is for Yahoo” it appears you are using VB6 labels i.e. “start1” which is not a good way to code as it is hard to debug and error prone.
If you need help with error handling in regards to recording to an error log, the following link explains how to do this by adding an unhandled exception handler which does not alter any of your existing code.
-
Aug 15th, 2011, 09:04 AM
#4
Re: Trying to send an email. Getting Error Message. Please Help!
Please use Code tags when posting please.
What is EASendMailObjLib? Does it get added to the setup you use for transporting to other machines?
-
Aug 15th, 2011, 09:05 AM
#5
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
Thanks for the posting tips. I tried revoing the labels but i still recieved the error. It is a microsoft box that pops up and wants me to send an error report, just saying that the program had to close cause of an error.
Last edited by jackjackkiwi; Aug 16th, 2011 at 10:05 PM.
-
Aug 15th, 2011, 09:10 AM
#6
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
EASendMailObjLib is a reference I use to send the email when program and I did not install it on the other computers. Is that the problem? If so, could I some how attach it to my program so when you download it it also installsEASendMailObjLib.
-
Aug 15th, 2011, 09:11 AM
#7
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
Thanks for the posting tips. I tried revoing the labels but i still recieved the error. It is a microsoft box that pops up and wants me to send an error report, just saying that the program had to close cause of an error.
If you want to download for yourself here:
http://bit.ly/potAr1
- Check to make sure the user has the correct .NET Framework client installed, this might very well be the problem.
- Look at using an unhandled exception handler as I suggested. The only reason for the unhandled exception handler to fail are reasons such as the item above
-
Aug 15th, 2011, 09:32 AM
#8
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
To have the unhandled exception handler do you just need to attach the folder from the download(on the article) to the folder with my project?
-
Aug 15th, 2011, 10:03 AM
#9
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
To have the unhandled exception handler do you just need to attach the folder from the download(on the article) to the folder with my project?
Look at the attached project. There is a folder called ExceptionHandling, copy this folder to your project then right click on the project, select add new, traverse to the new folder and select the following files while holding the CTRL key
MyApplication.vb
MyDialogs.vb
StackTracer.vb
WebAlert.vb
Click the right arrow on add button and select link.
That is it.
Please note this works only when running outside of the IDE. that is why under StartHere sub in the demo project I have
Code:
If My.Application.RunningUnderDebugger Then
. . .
To alert that the unhandled code will not work, this is not my design but Microsoft's.
-
Aug 15th, 2011, 11:21 AM
#10
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
Last edited by jackjackkiwi; Aug 16th, 2011 at 10:28 PM.
Reason: privacy
-
Aug 15th, 2011, 12:36 PM
#11
Re: Trying to send an email. Getting Error Message. Please Help!
Possibilities for the above issues
- You are not using Framework 3.5 or higher which is required
- You have Option Infer Off, needs to be Option Infer On under project properties
- You do not have the standard references in your project like System.xml, System.Xml.Linq.
The unhandled exception code as delivered is for Framework 3.5 higher that is not a project that was upgraded from say Framework 2.x.
These conclusions come from what I call a false error as shown below, the Close method exists but is showing up as an error because something else wheres is not correct thus we go back to the suggestions above.
Code:
Error 9 'Close' is not declared. File I/O functionality is available in the 'Microsoft.VisualBasic' namespace. C:\Documents and Settings\Jim Kabrich\my documents\visual studio 2010\Projects\Email Sender\Email Sender\WebAlert.vb 63 7 Email Sender
Lastly the project I gave you was justed created this morning, I simple did what I told you too do and it ran as expected.
Last edited by kareninstructor; Aug 15th, 2011 at 12:38 PM.
Reason: Added more info
-
Aug 15th, 2011, 12:56 PM
#12
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
I am using .net 4 cleint. Infer is ON, and the references you mentioned are also on. BTW thanks for all the help. Do you think that if these errors go away then the program will work on other computers? Do you want me to post my .exe file so you can see the error?
-
Aug 15th, 2011, 02:24 PM
#13
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
I am using .net 4 cleint. Infer is ON, and the references you mentioned are also on. BTW thanks for all the help. Do you think that if these errors go away then the program will work on other computers? Do you want me to post my .exe file so you can see the error?
Posting the executable is a) prohibited here b) would not assist in determining the underlying problem.
Did you try compiling the project I gave you or did you simply add the files as instructed to your project.
I would ask you to open my project, compile and run from Windows explorer. It should run just fine which leads back to an issue I mention in my last reply. I would be totally shocked if the project I gave you failed to compile or run.
-
Aug 15th, 2011, 06:47 PM
#14
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
The project cannot succesfully build with the VB files you attached. I started a new project and loaded your files. It still showed the 11 errors and wouldnt build (I assume when you say compile you mean build... sorry Im new at this)
-
Aug 16th, 2011, 06:23 AM
#15
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
The project cannot succesfully build with the VB files you attached. I started a new project and loaded your files. It still showed the 11 errors and wouldnt build (I assume when you say compile you mean build... sorry Im new at this)
That was not what I asked you to try and will not tell you the problem. Go back to this post and download the attachment followed by compiling the project without making any changes it will compile unless your computer is missing core Framework assemblies.
I did two test, compiled it myself, no errors, gave the zip to another developer and told them to compile it, they had no errors. So there is something with your environment causing issues or as mentioned before you added the items into the project wrong or the project(s) are not configured right for the project and the requirements are as mentioned before Framework 3.5 or higher with Option Strict On and Option Infer On. If you have Option Infer Off there would be five errors. If you had Option Strict Off there would be zero errors.
-
Aug 16th, 2011, 09:04 AM
#16
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
It is working now. I did not load the webalert.design, just all the codes. There is no errors now.
-
Aug 16th, 2011, 09:32 AM
#17
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
It is working now. I did not load the webalert.design, just all the codes. There is no errors now.
Let us know who you make out. As mentioned earlier I would suspect one possibility is the other computer which is crashing may be because they do not have the target Framework installed or are missing parts of the Framework, if that is the case then the error handler will not capture the error because of the above. If the Framework is properly installed then after the app crashes have the person send your the error log.
-
Aug 16th, 2011, 09:33 AM
#18
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
Last edited by jackjackkiwi; Aug 16th, 2011 at 10:27 PM.
Reason: Privacy
-
Aug 16th, 2011, 09:47 AM
#19
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
Ok this is the error it gave me when i tried to open it on another computer.
Code:
<?xml version="1.0" encoding="utf-8" ?>
- <Exceptions>
- <Exception>
<Date_Time>2011-08-16T10:10:02.515625-04:00</Date_Time>
<Message>An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</Message>
<StackTrace>at Prank_Email.My.MyProject.MyForms.Create__Instance__[T](T Instance) at Prank_Email.My.MyApplication.OnCreateMainForm() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()</StackTrace>
</Exception>
- <Exception>
<Date_Time>2011-08-16T10:28:39.921875-04:00</Date_Time>
<Message>An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</Message>
<StackTrace>at Prank_Email.My.MyProject.MyForms.Create__Instance__[T](T Instance) at Prank_Email.My.MyApplication.OnCreateMainForm() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()</StackTrace>
</Exception>
</Exceptions>
Here is the problem
Code:
The error is: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
This means you need to give that user the Power Pack files.
-
Aug 16th, 2011, 09:59 AM
#20
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
Is there any way I could make my program not rely on the powerpack? If not, were is there a download of the powerpack?
-
Aug 16th, 2011, 10:12 AM
#21
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
Is there any way I could make my program not rely on the powerpack? If not, were is there a download of the powerpack?
Under your project properties, References there is a button (do not have VS open now) called something like unused references, click it and see if PowerPack is listed, if so remove it and if not find out what control is being used and remove it for a standard control if possible, otherwise give the user the PowerPack files.
-
Aug 16th, 2011, 10:28 AM
#22
Thread Starter
Junior Member
Re: Trying to send an email. Getting Error Message. Please Help!
IT WORKS NOW! After removing the powerpack from references, a few errors came up. They all pointed towards a single line in my disign that I used to seperate 2 sections in the design of my project(not a line in the code, a physical line in the design). After deleting the line, which i can do without, it no longer relied on the powerpack. It works great now! Thanks so much for your help.
-
Aug 16th, 2011, 10:41 AM
#23
Re: Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
IT WORKS NOW! After removing the powerpack from references, a few errors came up. They all pointed towards a single line in my disign that I used to seperate 2 sections in the design of my project(not a line in the code, a physical line in the design). After deleting the line, which i can do without, it no longer relied on the powerpack. It works great now! Thanks so much for your help.
Your welcome.
-
Aug 16th, 2011, 06:32 PM
#24
Re: [RESOLVED] Trying to send an email. Getting Error Message. Please Help!
jackjackkiwi (or is it Jim Kabrich?)
You wouldn't be making some sort of email spamming program would you? That would be highly frowned upon in these forums, and of course would make users reluctant to help you in the future...
-
Aug 16th, 2011, 10:25 PM
#25
Thread Starter
Junior Member
Re: [RESOLVED] Trying to send an email. Getting Error Message. Please Help!
Why do you think my program is spam? I am very new at programming, so maybe im missing something, but i have created is a email sender that works with many email providers. Also, i am not jim, but rather he is the administrator of my computer. I edited out where it mentioned his name for privacy reasons.
If i am breaking any rules please tell me so i can fix it.
-
Aug 16th, 2011, 10:56 PM
#26
Re: [RESOLVED] Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
Why do you think my program is spam? I am very new at programming, so maybe im missing something, but i have created is a email sender that works with many email providers. Also, i am not jim, but rather he is the administrator of my computer. I edited out where it mentioned his name for privacy reasons.
If i am breaking any rules please tell me so i can fix it.
Perhaps because you removed the contents of post 18 which shows your program name is Prank_Email. There is no reason I can see for this to be removed but you did remove it.
Code:
<?xml version="1.0" encoding="utf-8" ?>
- <Exceptions>
- <Exception>
<Date_Time>2011-08-16T10:10:02.515625-04:00</Date_Time>
<Message>An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</Message>
<StackTrace>at Prank_Email.My.MyProject.MyForms.Create__Instance__[T](T Instance) at Prank_Email.My.MyApplication.OnCreateMainForm() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()</StackTrace>
</Exception>
- <Exception>
<Date_Time>2011-08-16T10:28:39.921875-04:00</Date_Time>
<Message>An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</Message>
<StackTrace>at Prank_Email.My.MyProject.MyForms.Create__Instance__[T](T Instance) at Prank_Email.My.MyApplication.OnCreateMainForm() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()</StackTrace>
</Exception>
</Exceptions>
-
Aug 17th, 2011, 09:27 AM
#27
Thread Starter
Junior Member
Re: [RESOLVED] Trying to send an email. Getting Error Message. Please Help!
I removed all the error messages because a) some had personal info and b) because the error messages might have shown info about my computer that hackers could use to get in to it. I really didn't examin what I was deleting I just deleted everything but the original script on the first post.
Next, to tell you the truth, when I started programming (about a week ago) I wanted to make a program that would trick my friends in to thinking I made a real program. It was named Prank Email because it only had the design of a program, no programming involved, because I had no idea how to program it. After I finished it (it was really just a design) I thought " why would I make a program that does nothing?" so I decided to research how to send real emails and I started to build it, but I had some errors. That brings us to now. After I started on the real project I noticed the name was still "prank email" but when I tried to change it in properties it gave me errors. So I let it be. And named everything else Email_Sender.
-
Aug 17th, 2011, 09:38 AM
#28
Re: [RESOLVED] Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
I removed all the error messages because a) some had personal info and b) because the error messages might have shown info about my computer that hackers could use to get in to it. I really didn't examin what I was deleting I just deleted everything but the original script on the first post.
Next, to tell you the truth, when I started programming (about a week ago) I wanted to make a program that would trick my friends in to thinking I made a real program. It was named Prank Email because it only had the design of a program, no programming involved, because I had no idea how to program it. After I finished it (it was really just a design) I thought " why would I make a program that does nothing?" so I decided to research how to send real emails and I started to build it, but I had some errors. That brings us to now. After I started on the real project I noticed the name was still "prank email" but when I tried to change it in properties it gave me errors. So I let it be. And named everything else Email_Sender.
Good enough
Not be belabor the why I will tell you there is nothing in the error messages that someone could use against you.
In regards to changing the project name, the only time there would be an issue is if the project name physically exists. Even after you can change a project name I would advise to go into the project properties and change the namespace to the same name as the project, otherwise you will have a new project name with the old namespace.
-
Aug 17th, 2011, 10:43 AM
#29
Re: [RESOLVED] Trying to send an email. Getting Error Message. Please Help!
Originally Posted by jackjackkiwi
Why do you think my program is spam?
Because I have been doing this a long time
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|