|
Imports EmailThread
'Imports System.Web.Mail
Imports System.Net.Mail
Public Class Email
Private Sender As MailAddress
Private Receipient As New MailAddressCollection
Private Subject As String
Private Server As String
Private Body As String
Private ServerPort As Integer
Private Priority As MailPriority
Private Credentials As System.Net.NetworkCredential
Private Smtp As SmtpClient
Private email As MailMessage
Private HtmlBody As Boolean
Private DelivNotification As New DeliveryNotificationOptions
Private ReplyTo As MailAddress
Private Cc As New MailAddressCollection
Private Attach As System.Net.Mail.AttachmentCollection
Public Sub SetSMTPClient(ByVal Host As String, ByVal Port As Integer _
, ByVal EnableSSL As Boolean)
Smtp = New SmtpClient
With Smtp
.Host = Host
.Port = Port
.EnableSsl = EnableSSL
End With
End Sub
Public Sub SetCredential(ByVal domain As String, ByVal Username As String _
, ByVal Password As String)
'we create new structure credential instance
Credentials = New Net.NetworkCredential
Credentials.Domain = domain
Credentials.UserName = Username
Credentials.Password = Password
End Sub
Public WriteOnly Property SetPriority()
Set(ByVal value)
Priority = value
End Set
End Property
Public WriteOnly Property SetReceipient()
Set(ByVal value)
Receipient.Add(value)
End Set
End Property
Public WriteOnly Property SetReplyTo()
Set(ByVal value)
ReplyTo = value
End Set
End Property
Public WriteOnly Property SetAttach()
Set(ByVal value)
Attach.Add(value)
End Set
End Property
Public WriteOnly Property SetCC()
Set(ByVal value)
Cc.Add(value)
End Set
End Property
Public WriteOnly Property Setfrom()
Set(ByVal value)
Sender = value
End Set
End Property
Public WriteOnly Property setSubject()
Set(ByVal value)
Subject = value
End Set
End Property
Public WriteOnly Property setSMTPServer()
Set(ByVal value)
Server = value
End Set
End Property
Public WriteOnly Property setBody()
Set(ByVal value)
Body = value
End Set
End Property
Public WriteOnly Property setServerPort()
Set(ByVal value)
ServerPort = value
End Set
End Property
Public Sub SendEmail()
' Attach = New Net.Mail.AttachmentCollection
Dim obj As Object
email = New MailMessage
With email
.From = Sender
For Each obj In Receipient
.To.Add(obj.ToString)
Next
.Subject = Subject
.IsBodyHtml = HtmlBody
.Priority = Priority
.DeliveryNotificationOptions = DelivNotification
.ReplyTo = ReplyTo
For Each obj In Cc
.CC.Add(obj.ToString)
Next
.Body = Body
'For Each obj In Attach
' .Attachments.Add(obj)
'Next
End With
obj = Nothing
With Smtp
.UseDefaultCredentials = True
' .Credentials = Credentials
'.DeliveryMethod = SmtpDeliveryMethod.Network
.EnableSsl = True
.Port = ServerPort
End With
Try
Smtp.Send(email)
Catch ex As Net.Mail.SmtpException
MsgBox(ex.ToString)
End Try
Smtp = Nothing
End Sub
End Class
Please any help
i keep getitng the error "Time out"
phatkin
|
|
|
|
|
Well i got it working now....Anybody want the code...ask me and leme paste it here...
it was quite simple and corrected my mistakes from dnzone
http://www.dnzone.com/forum/topic.asp?topic_id=284
am sooooo happy now..
phatkin
|
|
|
|
|
Hi ALL
i am migrating the vb application which con.tains the OCX Control
to that of the .net project i Choose Vb.Net
But when in .net i create maually aspx pages.
and i copy that class modules also...
but i am not getting that events.
How i will convert that OCX control into that of vb.net project so that i can access
the events......
waiting for your kind response.....
|
|
|
|
|
Make sure what application you want to develop.
Web application (web sites) cannot have ocx controls. I think you want to develop windows application and by mistake you have chosen web site/application because web sites/application will have aspx extension.
Just select language vb/c# and select Windows Application project (new project)
|
|
|
|
|
No dear i want to develop web application which is developed in vb and contains the contol... which gives the functionality of dialer,
O.K. Now when i converted into .net it is get converted to windows application but i want to develop a web application it is possible,...???
when i click on toolbox and say add item
then window opens in that i shoose COM Component tab then i insert
APS Client Control from the list and then i can able to see that control
in which i migrated the vb project.
But Now i want to that code manually to develop web project
for that i choose .net 2005 now and i create .aspx pages by using vb.net
as code behind when i follow same process to add APS Client Control
it not appearing in thr toolbox. However it is there is in list..
of COM Component tab why it is not coming....
Please Help me in this regard
i will be very much thankful..
|
|
|
|
|
my VB.net application uploads local files to server. Every second my application need to detect whether my application still connected to that server or lost connection, how i can detect the connection lost or still connected ? using shell or ping ? how to use it ?
Regards,
Chee ken
|
|
|
|
|
|
firstly I would not check the connection every second, I would only check it just before I upload the file.
I use a function like the following to check if a connection exists :-
Public Shared Function IsWebSiteAvailable(ByVal Address As String) As Boolean<br />
Try<br />
Dim oUrl As New System.Uri(Address)<br />
Dim oWebRequest As System.Net.WebRequest = System.Net.WebRequest.Create(oUrl)<br />
Dim oResponse As System.Net.WebResponse = oWebRequest.GetResponse<br />
oResponse.Close()<br />
oWebRequest = Nothing<br />
Return True<br />
Catch<br />
Return False<br />
End Try<br />
End Function
There I would the code the upload as follows
If IsWebSiteAvailable("www.mysite.com") Then<br />
DoUpload()<br />
Else<br />
MessageBox.Show("Internet connection unavailable.")<br />
End If<br />
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
I want to put a Double Quote (") in a string. if I give it in a string, then the string terminates at the position where the Double Quote is put.
Can anybody suggest how to put a Double Quote in a string ?
Thanks In advance.
Sekhar
|
|
|
|
|
Try """".
e.g. "This is a ""TEST"" string"
|
|
|
|
|
Hi,
In regards to your query I would like to inform you that in order to print double qoutes in a sting we have to use two double quotes (e.g., ""). We can print the double quotes in a string as follows:
BEGIN CODE
Dim str As String = "I ""Love"" VB "
MsgBox(str)
END CODE
The output will be I "Love" VB.
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Use ChrW(34)
Like this:
TextBox1.Text = ChrW(34) & "This is a string." & ChrW(34)
The output would be:
"This is a string."
You can put any character in ChrW(.) by looking at this page: http://www.utoronto.ca/webdocs/HTMLdocs/NewHTML/iso_table.html[^]
As you can see, the double quote char is decimal 34.
http://www.themightyatom.nl
|
|
|
|
|
Can anyone help with the following? I need my Local System Service to check for the time of last user activity on an XP box with multiple logins using fast user switching. I've tried using a .dll (see link at the Imports statement) to hook the keyboard (intending to set a global TickCount variable on KeyDown events) after setting the service to interact with the desktop of the most recently logged in user. I can attach to the process from the VS debugger and step through everything without any error, but the KeyDown handler never gets called. I know the following "snippet" is still quite a bit to wade through but I'm stumped and getting desperate. Anyone see where I'm going wrong - or know an easier way of getting a global "LastInputTicks" value? How do the Windows Power Management routines know when there was last a sign that the user is still alive? Thanks in advance to anyone who spares the time.
<code>Imports WindowsHookLib 'http://www.codeproject.com/KB/vb/WindowsHookLib.aspx?
Friend WithEvents KbHook As LLKeyboardHook
Private Declare Function OpenWindowStation Lib "user32.dll" Alias "OpenWindowStationA" (ByVal lpszWinSta As String, ByVal fInherit As Boolean, ByVal dwDesiredAccess As Int32) As Int32
Private Declare Function OpenDesktop Lib "user32.dll" Alias "OpenDesktopA" (ByVal lpszDesktop As String, ByVal dwFlags As Int32, ByVal fInherit As Boolean, ByVal dwDesiredAccess As Int32) As Int32
Private Declare Function SetProcessWindowStation Lib "user32.dll" (ByVal hWinSta As Int32) As Int32
Private Declare Function SetThreadDesktop Lib "user32.dll" (ByVal hDesktop As Int32) As Int32
'Start the service with a login handler
Protected Overrides Sub OnStart(ByVal args() As String)
Dim objLog As EventLog = New EventLog("Security")
AddHandler objLog.EntryWritten, AddressOf SecurityLog_OnEntryWritten
objLog.EnableRaisingEvents = True
End Sub 'OnStart
Private Sub SecurityLog_OnEntryWritten(ByVal [source] As Object, ByVal e As EntryWrittenEventArgs)
'Only want user login events
If e.Entry.InstanceId <> 528 OrElse e.Entry.UserName.Contains("SERVICE") Then
Return
End If
MakeServiceInteractive()'http://www.codeguru.com/forum/showthread.php?t=238942
'Service then does other stuff on separate threads I'd like to abort when there's no active user
End Sub 'SecurityLog_OnEntryWritten
Private Sub MakeServiceInteractive()
Dim lngDefaultDesktop As Int32
Dim lngWinSta0 As Int32
lngWinSta0 = OpenWindowStation("WinSta0", False, &H37F)
If SetProcessWindowStation(lngWinSta0) <> 0 Then 'success
lngDefaultDesktop = OpenDesktop("Default", 0&, False, &H8L)
If SetThreadDesktop(lngDefaultDesktop) <> 0 Then 'success
KbHook = New LLKeyboardHook
KbHook.InstallHook()
WriteLog("KbHook state: " & KbHook.GetState.ToString())
'I can step through to a log entry of "KbHook state: Installed" so all seems well, but handler never gets hit.
End If
End If
End Sub 'MakeServiceInteractive
Private Sub KbHook_KeyDown(ByVal sender As Object, ByVal e As WindowsHookLib.KeyEventArgs) Handles KbHook.KeyDown
WriteLog(e.KeyCode.ToString & " Pressed") 'never gets called :confused:
End Sub 'KbHook_KeyDown</code>
|
|
|
|
|
I have 2 treeview on my form and I want to add drag and drop functionality from Treeview1 to Treeview2.
I got the sample code from the net.I tried after making some changes in the code and also tried by copying the same code but its not working.
Down is the samle code which I got from the internet.
[Code]
Private Sub TreeViewExample_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
treeTwo.AllowDrop = True
treeOne.AllowDrop = True
End Sub
Private Sub treeOne_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles treeOne.MouseDown, treeTwo.MouseDown
Dim tree As TreeView = CType(sender, TreeView)
Dim node As TreeNode
node = tree.GetNodeAt(e.X, e.Y)
tree.SelectedNode = node
If Not node Is Nothing Then
tree.DoDragDrop(node.Clone(), DragDropEffects.Copy)
End If
End Sub
Private Sub treeTwo_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles treeOne.DragOver, treeTwo.DragOver
Dim tree As TreeView = CType(sender, TreeView)
e.Effect = DragDropEffects.None
If Not e.Data.GetData(GetType(TreeNode)) Is Nothing Then
Dim pt As New Point(e.X, e.Y)
pt = tree.PointToClient(pt)
Dim node As TreeNode = tree.GetNodeAt(pt)
If Not node Is Nothing Then
e.Effect = DragDropEffects.Copy
tree.SelectedNode = node
End If
End If
End Sub
Private Sub treeTwo_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles treeOne.DragDrop, treeTwo.DragDrop
Dim tree As TreeView = CType(sender, TreeView)
Dim pt As New Point(e.X, e.Y)
pt = tree.PointToClient(pt)
Dim node As TreeNode = tree.GetNodeAt(pt)
node.Nodes.Add(e.Data.GetData(GetType(TreeNode)))
node.Expand()
End Sub
End Class
[/Code]
Can I body tell me where is the problem in the above code or any sample code which is working will be appreciated.
Thanks in advance
Ejaz
|
|
|
|
|
Sample works fine in my own app. What's not working?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I tried the same code in vb.net 2003 and it was working but in vb.net 2005 it is not working.In 2005 it is not working.
It is not adding the node in the targeted treeview while dropping.
|
|
|
|
|
How can 'Instance' be best explained in Visual Basic
|
|
|
|
|
roger6897 wrote: How can 'Instance' be best explained in Visual Basic
Well, it depends on what you mean by "instance"?
I'm guessing you mean in terms of object oriented programming (OOP)
An object is an instance of a class. A class is a type.
You create a new instance of a class with the New keyword.
Dim w As Widget = New Widget(someParameter)
w is the reference to the object (the instance of the class.
Widget is the name of the class
New instantiates the instance of the class.
Does that answer your question?
|
|
|
|
|
Hi all, Please help me with this... I'm developing a system using pocket pc.. i can connect to database (sql server mobile (northwind.sdf) - using sqlClientCe).. but at the same time i need to connect to (SQL SERVER - Northwind database)... my problem is.. i cant make any connection to a SQL Server to fetch my datas... thanks in advance..
|
|
|
|
|
Hey all.
I got a problem wih Aaron Eldreth's Real Time SynTax Colorizing tutorial/article. I've posted the problem on his article page, but i don't think he'll respond, since he made his last post in 2004, so i don't think he visits here anymore.
Thats why im posting the exact same issue here in the VB.NET forum hoping that some else has the solution. So here's the original post:
Hi Aaron!
Awesome code! Im using this in my application which is a front end compiler. This compiler creates a log file, and i want to use your code do colorize error messages in that logfile.
But anyway, something strange is happening, check it out: Screenshot
As you can see, something is wrong:
The word "hlcsg is colored yellow, which is working fine. But there's another instance of this word (Current hlcsg settings) in the log which is not colored yellow! Why?"
Also note that the word "estimate" is colored purple, but i haven't added this word to the Keywords on the left! What the.
The words "max texture memory" (below the purple estimate) is not colored at all.
The word "zhlt.wad" is colored red, but the word "wadinclude" is partially colored red, only the first character and the last character of that word is left white (which is the default color) and it not even in the Keywords! Below the second zhlt.wad is another instance of zhlt.wad, but this one is left white, while it should be colored red as well.
The words "discarded from clipping hulls" is colored greenyellow, only the last character of the word "hulls" is left white.
This is really weird, and i can't figure it out.
I guess this has something to do with text encoding, since the log text is actually being read from a .log file on my hard drive.
When i empty the RichtTextBox and start to type in words manually, it works fine.
If you know why this is happening and how to fix this, please tell me how, i would really appreciate it and ill give you credits in my app when i release it.
I hope knows what the problems is, because i can't figure this out. Its so weird.
- Atom
http://www.themightyatom.nl
|
|
|
|
|
You'll notice that further comments also discount the quality of this article due to its poor performance over many lines. This is because the way its done is not dealing with only the visible lines. Perhaps you should seek an alternative syntax coloring method. Not sure exactly what aaron uses, but, perhaps developing your own using Regex would be a good bet. I'd give you my syntax highlighting code but its still under construction, (i.e. only just started 2 days ago).
|
|
|
|
|
Hmmm, i tried RegEx numerous times, but never got it working, its kinda complicated to me.
If you have some code for me that i can use, i would appreciate it, and ill credit you for that.
I've trying to get this (coloring error message in my log file) for several weeks now, without any results. That article by Aaron was the only thing that (kinda works) if i wasn't for the fact that it has poor performance, like you said.
I really need some help. If you can, please do so.
Thanks.
- Atom.
http://www.themightyatom.nl
|
|
|
|
|
i emailed you some stuff, its just a modification of aarons. So no credit for me. I hope it works right for you. If not we will have to keep trying.
|
|
|
|
|
I don't have anything in my inbox.
It might have been removed by the spamfilter.
Could you send it to mdw DOT breddels1 AT hccnet DOT nl instead?
http://www.themightyatom.nl
|
|
|
|
|
I am using a FillBy method to get certain rows from the Table Adapter. How do I get the number of rows that are returned from the query?
|
|
|
|