|
See what happens if you follow Lucs' suggestion.
I'll watch the thread, in case you come back.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Paulo,
I have a C# program that, amongst a lot of other stuff, contains mail code, basically identical to yours (the synchronous version, that is):
MailMessage msg=new MailMessage();
...
SmtpClient client = new SmtpClient(server);
client.Send(msg);
The only difference is my client is constructed with the server's name as a parameter.
My program successfully sends three mails without exiting at all.
My best guess is your observation somehow is wrong.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Thursday, March 26, 2009 4:23 PM
|
|
|
|
|
Hi Luc/Henry,
I tried to build the SMTP client as Luc suggested but did not work either.
However, I found what the problem was: follow me.
when I started this project I did not know if I'll be using MAPI or SMTP, so I wrote 2 methods. Testing the MAPI time ago (with MAPI we use here Exchange Server), when the email is sent ExchangeServer pops a dialog box telling me that a program (my application) "is trying to send an email on your behalf" and give me an OK and CANCEL buttons. Once I hit OK, the email is sent.
That is the key: I'm testing the code using my own equipment, sending emails to me to see if it works or not. Did you see what happened?
SMTP does not have all Exchange Server features and does not issue a dialog asking for authorization, but it keeps waiting because I'm sending emails from my equipment to myself, but the user is not me, is my application, using my credencials!
As a proof of concept for this theory, I installed the application in another computer in the network and it worked fine, no more need to close the sending thread!
Nothing is wrong with those VB and C# codes, just the way I'm testing.
So, Luc/Henry, I really appreciate your effords and time spent to help me and it was a good felling having someone in the other side to discuss with my tech problems.
Thank you!
Paulo
|
|
|
|
|
Hi Paulo,
glad you got it working.
However I'm not familiar with Exchange Server, and I do not quite follow your reasoning.
Are you saying:
1. Exchange Server does not want to accept your app sending something until the app exits?
2. Exchange Server does not deliver the newly received message as long as the app is running, because the app is impersonating you and "you" (the app) are not asking for incoming mail until the app exits and your regular mail client becomes active again?
Furthermore: would your app succeed in sending without exiting, if you did close your mail client beforehand?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi Luc,
About exchange server, it asks for authorization because the app (that is not me) is using my credencials to send email. This also happens when you get a virus kind Trojan and it tries to send emails from your equipment (it did happened before with me). The antivirus also catch this kind too.
I noticed that because the confirmation dialog box exchange server issued. But now I'm not using exchange server and MAPI, I'm using our SMTP server and it does not issue a dialog. If I issue 3 or 4 emails all go to the SMTP queue and all are sent only when the task is closed.
But if I use other equipment than mine, it works fine.
I tried to close the mail session bforehand, but it did not work either.
Anyways, it is something to keep in mind for our future development needs.
Thanks Luc.
Anytime.
Paulo
|
|
|
|
|
Ok I'm trying to make a simple inkball type game.
But, I'm getting some wierd errors. Here is my code.
Public Class Form1
Public ink() As Point
Public g As Graphics = Me.CreateGraphics
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim p = ink.Length
ink(p).X = e.X
ink(p).Y = e.Y
End If
End Sub
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
For Each p As Point In ink
g.DrawRectangle(Pens.Black, New Rectangle(p.X, p.Y, 1, 1))
Next
End Sub
End Class
I've tried changing g to be Panel1.creategraphics, since the panel is what it would be drawing on but that causes even more problems. The errors I am getting are all 'Object Reference Not set to an instance of an object."
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
I really don't understand what you are trying to do , but the error you are getting is because you have not initialized the array ink() , it is still Nothing and hence are getting the error , was not able to understand the logic you are trying to apply , looking at the code it don't think it is going draw anything . The only thing i can suggest is initialized the array before using it.
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
The graphics object you created is one for the form, not the panel. You get the graphics object for the panel from the Panel1 Paint event, like this:
Private Sub Panel1_Paint(ByVal sender as System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim g As Graphics = e.Graphics
For Each p As Point In Ink
g.Draw....
Next
End Sub
But, of course, you'll have to modify the paint code to check to see if there are any points at all in the Ink array.
|
|
|
|
|
i am just wondering if anyone know(or have links) of a way to save a array inside the application code?
If at first you don't succeed
redefine success
J.Hardy
modified on Wednesday, March 25, 2009 9:52 PM
|
|
|
|
|
Dim p(3) As Point 'create an array of 4 points (1-3 and 0)
p(0) = New Point(640, 480) 'assign values to the points
p(1) = New Point(800, 600)
p(2) = New Point(1280, 748)
p(3) = New Point(769, 999)
Dim r As New String("") 'create a blank string
For Each ipoint As Point In p 'loop through the points
r &= "Point is located at: " & ipoint.ToString & vbNewLine 'write a string about the point
Next
MessageBox.Show(r) 'display the string with the info
Hope it helps!
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
sorry allow me to explain better, when i publish my application to a exe i need to store a array inside the exe(this will make the application grow in size), so next time when i open it the contents of the array will be there
If at first you don't succeed
Redefine success
J.Hardy
|
|
|
|
|
You don't save data in your exe, you save it in an external file (for example app.config or as user settings) and load it in - unless you are talking about an hardcoded set of values, in which case the code to populate the array will be in the exe anyway.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
dam, oh well, thanks anyway
If at first you don't succeed
Redefine success
J.Hardy
|
|
|
|
|
How can i make the file executable by someone else with out the need of downloading a visual basic program onto their computer?
|
|
|
|
|
Search for click-once deployment.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
|
Hey got a question about visual basic. Got a project for college to write a small code for a button to search an array called 'Members(0)'. The programme basically gets the user to input data via a input box (name, age only) and this button needs to find the LONGEST name in the array. And display it in the text box called 'txtResult.text'
Here's the code I have so far;
Private Sub btnLongName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLongName.Click
Dim LongName As String
Dim LengthOfLongestName As Integer
LongName = Members(0).Name
LengthOfLongestName = Len(Members(0).Name)
End Sub
End Class
|
|
|
|
|
There are two things I would like to point out:
The first, is that nowhere in your code, do you examine all of the elements of Members(0) . You only examine one element.
In order to resolve this problem you need to learn how to iterate through the elements of the array. To find out how to do that, why not search MSDN or google for the words in bold.
The second thing is fairly small:
Your code:
LongName = Members(0).Name
LengthOfLongestName = Len(Members(0).Name)
The first line gets the name from the array element. Accessing stuff in arrays is reasonably costly in terms of the processing required. So, in the second line, don't get the length by diving into the array again, use the name you have already fetched.
Modified code:
LongName = Members(0).Name
LengthOfLongestName = Len(LongName)
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks for the info but the meat of the matter is on actually how to search for the longest name in that array which i'm struggling with big time >< Sorry to be so general, I'm fairly new to VB
I've edited it a bit more;
Private Sub btnLongName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLongName.Click
Dim LongName As String
Dim LengthOfLongestName As Integer
LongName = Members(0).Name
LengthOfLongestName = Len(LongName)
If LongName Then
End If
txtResult.Text = "The longest name is " & LongName & " ."
End Sub
End Class
modified on Wednesday, March 25, 2009 6:43 PM
|
|
|
|
|
OK.
Some more clues.
Since you are interested in the longest name, look at the first element (your code already does that) and set the LengthOfLongestName variable to its length (your code already does that), and set the LongName variable to the name of the first element (your code already does that). So you've made a good start.
Then look at the length of the next element and if, but only if it is greater than LengthOfLongestName , set LengthOfLongestName to this length and set LongName to the Name of this element.
Then do the same for the next element, and so on, until you have examined all of the elements.
When you have done this, LengthOfLongestName will hold the length of the longest name and LongName will hold the longest name itself.
That's it.
Iterating over an array is such a basic operation that there are thousands and thousands of examples in MSDN and elsewhere.
I'm not going to write it for you. Do some research find an example and try to code it yourself. To start with it doesn't have to do the longest name thing. Try just getting it to list the elements, then when you are sure you understand what's happening, do the longest name bit.
Once you have done some coding and got at least part of it working, come back if you get stuck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: Once you ... got at least part of it working, come back if you get stuck.
This begs for an article entitled "How to get unstuck at the very start?"
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Picky, picky, picky.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Private Sub subLongest()
Dim arr(100) As String
arr(0) = "aa"
arr(1) = "bbb"
arr(2) = "cc"
arr(3) = "ddddd"
arr(4) = "aa"
arr(5) = "bbb"
arr(6) = "cc"
Dim maxLenIndex As Int16 = 0
Dim maxLen As Int16 = arr(0).Length
For ii As Int16 = 1 To 100
If arr(ii) IsNot Nothing Then
If arr(ii).Length > maxLen Then
maxLen = arr(ii).Length
maxLenIndex = ii
End If
End If
Next
MsgBox("Longest element is " & arr(maxLenIndex))
End Sub
|
|
|
|
|
OK.
That's your code.
You have made a lot of progress, since the last code-sample you posted. Well done!
Now what happens when you run it?
Do you get errors? If so, what are they?
Does it give an incorrect answer?
What is the problem that you need help with?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|