- ©«¤l
- 46
- ¥DÃD
- 18
- ºëµØ
- 0
- ¿n¤À
- 67
- ÂI¦W
- 0
- §@·~¨t²Î
- WINXP,win7
- ³nÅ骩¥»
- office2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¨{¤l¸Ì
- µù¥U®É¶¡
- 2010-5-22
- ³Ì«áµn¿ý
- 2011-10-27
|
[µo°Ý] ºÊ±±¥Ø¿ý²§°Êlog & VB¶l¥óµ{¦¡
Dear ¤j¤jÌ¡A
¤p§Ì³Ìªñ¦b¼g¤@¥\¯àªºVB¡C
¨ä¥\¯à¬O¯à°÷ºÊ±±1¸ê®Æ§¨©M¤l¥Ø¿ýªºÀɮײ§°Ê(·s¼W¡B§R°£¡Bקï)ªº®É¶¡log°O¿ý¡C
¨Ã¥B¨C¦³²§°Ê¡A´N¥ÎMailµo¥X³qª¾¡C
Mail §tlogªþ¥óÀɮסA©Î±Nlogªº¤º®e¶K¤W¶l¥ó¤º¤å¡C
¦ý¤p§Ì¤~è¾Ç¤£¤[¡A¹ï©ó°j°éif ³o¨ÇÆ[©À«Ü³¡·|...¡C
¥H¤U¨âÓµ{¦¡¦pªG³æ¿W°õ¦æ³£¨S¦³°ÝÃD¡C
1Ó¬Omailªºclass¡A1Ó¬OºÊ±±¥Ø¿ýªºclass¡C
·Q½Ð±Ð¤j¤j¦pªG¨âÓµ{¦¡ªº¥\¯àµ²¦X¤@°_¡C
À³¸Ón«ç»òקï©O?
ÁÂÁ¦U¦ì¤j¤j~- Public Class Mail001
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim To_Address As String = "[email protected]"
- ' ³]©wSMTPserver
- Dim SMTP_Server As New Net.Mail.SmtpClient("google.smtp.com")
- Dim Mailmsg As New System.Net.Mail.MailMessage
- Dim MailBodyHtml As String
- ' ³]©w¤@Ó«H¥óªºªþÀÉ
- Dim mail_attachment As New System.Net.Mail.Attachment("C:\VB_Mail.rar")
- Mailmsg.IsBodyHtml = True ' ¬°html¤º®e®æ¦¡
- ' ¦¹«Hªº±H¥ó¤H
- Mailmsg.From = New Net.Mail.MailAddress("[email protected]", "webb")
- Mailmsg.Subject = "test_webb"
- MailBodyHtml = "Mail Message First"
- MailBodyHtml &= "Mail Message Second"
- Mailmsg.Body = MailBodyHtml
- ' §âªþÀÉ¥[¤J¨ìMail
- Mailmsg.Attachments.Add(mail_attachment)
- ' ±N¦r¦ê¸Ìªº;¤À¬°¦hÓ¦¬¥ó¤H
- For Each MA As String In To_Address.Split(";")
- Mailmsg.To.Add(New Net.Mail.MailAddress(MA, "[email protected]"))
- Next
- ' ±K¥ó°Æ¥»¦¬¥ó¤H
- ' Mailmsg.Bcc.Add(New Net.Mail.MailAddress("[email protected]"))
- ' Mailmsg.Priority = Net.Mail.MailPriority.Normal
- ' Smtp(Server) ªº±b¸¹»P±K½X
- SMTP_Server.Credentials = New System.Net.NetworkCredential("Liuxxx", "123456")
- SMTP_Server.Send(Mailmsg)
- MessageBox.Show("Message sent.")
½Æ»s¥N½X- ¥ý±q¤u¨ã½c´¡¤J¥H¤Uª«¥ó
- txt_watchpath ' TextBox (for folder path)
- btn_startwatch ' Button (start watching)
- btn_stop ' Button (stop watching)
- txt_folderactivity ' Textbox (folder activity)
- Imports System.IO
- Imports System.Diagnostics
- Public Class webb_000
- Public watchfolder As FileSystemWatcher
- Private Sub btn_startwatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_startwatch.Click
- watchfolder = New System.IO.FileSystemWatcher()
- 'this is the path we want to monitor
- watchfolder.Path = txt_watchpath.Text
- 'Add a list of Filter we want to specify
- 'make sure you use OR for each Filter as we need to
- 'all of those
- watchfolder.IncludeSubdirectories = True 'ºÊµø¤l¥Ø¿ý
- watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
- watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _
- IO.NotifyFilters.FileName
- watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _
- IO.NotifyFilters.Attributes
- ' add the handler to each event
- AddHandler watchfolder.Changed, AddressOf logchange
- AddHandler watchfolder.Created, AddressOf logchange
- AddHandler watchfolder.Deleted, AddressOf logchange
- ' add the rename handler as the signature is different
- AddHandler watchfolder.Renamed, AddressOf logrename
- 'Set this property to true to start watching
- watchfolder.EnableRaisingEvents = True
- btn_startwatch.Enabled = False
- btn_stop.Enabled = True
- 'End of code for btn_start_click
- End Sub
- Private Sub txt_folderactivity_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_folderactivity.TextChanged
- End Sub
- Private Sub logchange(ByVal source As Object, ByVal e As _
- System.IO.FileSystemEventArgs)
- If e.ChangeType = IO.WatcherChangeTypes.Changed Then
- txt_folderactivity.Text &= "File " & e.FullPath & _
- "¤wקï" & Now & vbCrLf
- End If
- If e.ChangeType = IO.WatcherChangeTypes.Created Then
- txt_folderactivity.Text &= "File " & e.FullPath & _
- " has been created¤w«Ø¥ß" & Now & vbCrLf
- End If
- If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
- txt_folderactivity.Text &= "File " & e.FullPath & _
- " ¤w§R°£" & Now & vbCrLf 'Now ´N¬O¥Ø«e¤é´Á®É¶¡
- End If
- End Sub
- Public Sub logrename(ByVal source As Object, ByVal e As _
- System.IO.RenamedEventArgs)
- txt_folderactivity.Text &= "File" & e.OldName & _
- " has been renamed to ¤w§ó¦W¬°" & e.Name & vbCrLf
- End Sub
- Private Sub btn_stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_stop.Click
- ' Stop watching the folder
- watchfolder.EnableRaisingEvents = False
- btn_startwatch.Enabled = True
- btn_stop.Enabled = False
- End Sub
- End Class
½Æ»s¥N½X |
|