|
I like to send emails from vb.net. Which is the best method? Any codings?
Thanks
|
|
|
|
|
Hi,
sending mail is easy, receiving it is much more complex.
The details depend on the circumstances. It would be very easy if you have a mail client on your PC, or if you have an ISP provider offering mail (most do).
This is some C# code I am using:
MailMessage msg=new MailMessage();
...
SmtpClient client = new SmtpClient(server);
client.Send(msg);
where server is the mailserver name provided by the ISP.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Just an addendum for the OP; some SMTP servers require authentication. You may also have to alter the port. In order to get to these, set the properties of the SmtpClient instantiation
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
How can i remove the controlbox or the close control in the messagebox in vb .net?
|
|
|
|
|
Create your own messagebox form.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You can't. If you want that gone, you'll have to create your own MessageBox class from a Form, just like any other in your app.
|
|
|
|
|
Hi
Here is the code that I've written.
Private Function CheckControl(ByVal ctrlName As String) As Boolean
Dim ctrl As Control
Dim blnResult As Boolean
For Each ctrl In Me.Controls
If ctrl.Name = ctrlName Then
blnResult = True
End If
Next
Return blnResult
End Function
The problem is that it does not give the correct answer i.e. even if the control exists, it returns false.
Thanks
reman
|
|
|
|
|
Remember a control (panel, groupbox etc) can have a collection of controls, you are only checking the top level of controls on the form. You need to check if a control has controls and call the same procedure from within your foreach loop. Example
For Each ctrl In Me.Controls
If ctrl.Name = ctrlName Then
blnResult = True
End If
CheckControl(ctrl)
Next
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Amer Rehman;
If you are using .Net Framework 2.0 or higher you can use the Control.ControlCollection.Find Method to find a control. The second parameter states to search all child controls as well as shown in the code snippet below.
Private Function CheckControl(ByVal ctrlName As String) As Boolean
Dim blnResult As Boolean = False
If (Me.Controls.Find(ctrlName, True).Length > 0) Then
blnResult = True
End If
Return blnResult
End Function
Fernando
|
|
|
|
|
Hi all,
I have a program, in which it will list all the window handles and window names. (hwnd, window name). Please any one tell me how to get all currently running windows handles and window names using API. give a code snippet please.
Ramesh Sambari
Knowledge is like honey.
Collect it, to make life sweet.
|
|
|
|
|
First Google hit[^]
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
specialdreamsin wrote: give a code snippet
You are lucky CG is feeling guilty about having had another fool delete his message in shame. Asking for the code is rude and likely to get you abused, asking a very simple question without doing some research (IE Google or MSDN search) will also get you flamed.
You saving grace is that you used your keyboard and you were not rude - enjoy your research, if you have trouble with the code then come back and ask about a problem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
My software is running in Background and i want to set Hot Key Setting for showing it.So please help me how can it resolve.
Thanks
If you can think then I Can.
|
|
|
|
|
There are multiple ways of creating this functionality. Here's one approach;
There's a "hotkey" that you can define for a shortcut. Right-click on any icon in the quicklaunch-taskbar, and you'll see where you can enter a "shortcut key" to launch the application.
If the application is launched, then check whether your application is already running. If it is, send it a message that it should restore it's main window
I are troll
|
|
|
|
|
Hi,
you can set a keyboard hook see this[^] for a example, it is in C# but can easy be converted to VB.NET.
Regards: Didi
|
|
|
|
|
This also requires that the app be running all of the time in order to work. Your solution is way too complex for the problem at hand, being overkill for something that can be done with a shortcut at installation time.
|
|
|
|
|
...he sayed, that his app is running in the background. So, if I understand him right, he is looking for a hook and not just for a hot-key to start the app. But anyway, he has both methods showed to him now, so he can choose.
Regards: Didi
|
|
|
|
|
Thank you DidiKunz.
If you can think then I Can.
|
|
|
|
|
Well, I don't know how I missed that. Sorry about that.
|
|
|
|
|
Hello,
Recently I doing a vb.net file manager with drag & drop file to listview.After a file is drag to listview,I want to launch the file when DoubleClick the file in my listview.My problem is Listview_DragEnter event conflict with Listview_DoubleClick.If I doubleClick the listview,Listview_DoubleClick is not working.Below is my code:
Private mouseisdown As Boolean = False
Private Sub ListView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.All
Dim myfile() As String
Dim i As Integer = 0
myfile = e.Data.GetData(DataFormats.FileDrop)
For i = 0 To myfile.Length - 1
Dim ico As Icon = Icon.ExtractAssociatedIcon(myfile(i))
ImageList1.Images.Add(ico)
Dim listview As New ListViewItem
Dim location As New ListViewItem.ListViewSubItem
listview.Text = myfile(i).Substring(myfile(i).LastIndexOf("\") + 1)
location.Text = myfile(i)
listview.SubItems.Add(location)
listview.ImageIndex = ImageList1.Images.Count - 1
ListView1.LargeImageList = ImageList1
ListView1.Items.Add(listview)
listview = Nothing
Next
End If
End Sub
Private Sub ListView1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.All
End If
End Sub
Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown
mouseisdown = True
End Sub
Private Sub ListView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseMove
If mouseisdown = True Then
If ListView1.SelectedItems.Count > 0 Then
ListView1.DoDragDrop(ListView1.SelectedItems(0).Text, DragDropEffects.Move)
End If
End If
mouseisdown = False
End Sub
Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
If ListView1.SelectedItems.Count > 0 Then
Process.Start(ListView1.SelectedItems(0).SubItems(1).Text)
End If
End Sub
Yours quick prompt would be much appreciated.
yutu
|
|
|
|
|
Drag and Drop and Double click have nothing to do with each other. Remove the two Mouse handlers and you're code should work just fine.
|
|
|
|
|
I have a series of text boxes I want to add a popup menu to them. When someone right clicks on a text box, I want the popup menu to appear, then when they select an item I need to perform some action, based on which of the text boxes they were right clicking on.
My declaration
Private txtSlot() As System.Windows.Forms.TextBox
Then build the txtSlots:
Private Sub createTxtSlotArray()
Dim i As Short
ReDim txtSlot(10)
For i = 1 To 10
txtSlot(i) = New System.Windows.Forms.TextBox
With txtSlot(i)
.Tag = i
AddHandler .Click, AddressOf Me.txtSlot_Mouseclick
End With
Next
Me.Controls.AddRange(txtSlot)
then try to get it
Private Sub txtSlot_Mouseclick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click
Debug.Write("Clicked " & sender.tag()) 'for real I will set a global variable here so I know the ID
' what to do here to get popup? and make it pop up
?????
End Sub
I thought someting like
contextmenu1.Show (contextmenu1,????) ' where to I get pos (second parameter)?
Any help is appreciated
thanks
|
|
|
|
|
The position can be anything you want. If you want it to be where the mouse was clicked, you just have to get the mouse position from the event args in your mouse move handler (the e argument.)
|
|
|
|
|
but what would that be under the event args, nothing looks close
I am thinking I need to put a command such as:
ContextMenu1.show(control as system.windows.forms.control, pos as system.drawing.point)
Intellisense suggests nothing for the first parameter, and I am not sure what it is asking for. (the name of something?) I have no idea what to provide for the second parameter, or where to get the mouse position from.
modified on Friday, June 12, 2009 4:03 PM
|
|
|
|
|
Handle the MouseMove event, look in its event args, keep the values in a class scoped variable. Then, when the Click event happens, you've already got your position.
|
|
|
|