VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - vb设计数据库电子邮件程序(6)
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8278, 日期:2001-06-14
vb设计数据库电子邮件程序
crystal编译
--------------------------------------------------------------------------------


  获得和修改注册表设置

注释:-- Property form load event
注释:-- Load all registry settings
DSNCombo = GetSetting("EmailMaker", "Database", "DSN", "OLE_DB_NWind_Jet")
TableCombo = GetSetting("EmailMaker", "Database", "Table", "Customers")
FieldCombo.Text = GetSetting("EmailMaker", "Database", "Field", "ContactName")
UserNameText = GetSetting("EmailMaker", "Database", "User Name", "")
PasswordText = GetSetting("EmailMaker", "Database", "Password", "")
MailboxCombo = GetSetting("EmailMaker", "Mailbox", "Mailbox", "Mailbox - NorthWind")
FolderCombo = GetSetting("EmailMaker", "Mailbox", "Folder", "Drafts")
FromText = GetSetting("EmailMaker", "Mailbox", "From", "NorthWind")
SecondaryOption = GetSetting("EmailMaker", "Secondary", "On", 0)
SecondFieldCombo.Text = GetSetting("EmailMaker", "Secondary", "Field", "")

注释:-- Apply button注释:s OnClick event
Private Sub cmdApply_Click()
注释:-- Save all settings to registry

SaveSetting "EmailMaker", "Database", "DSN", DSNCombo.Text
SaveSetting "EmailMaker", "Database", "Table", TableCombo.Text
SaveSetting "EmailMaker", "Database", "Field", FieldCombo.Text
SaveSetting "EmailMaker", "Database", "User Name", UserNameText
SaveSetting "EmailMaker", "Database", "Password", PasswordText
SaveSetting "EmailMaker", "Mailbox", "Mailbox", MailboxCombo
SaveSetting "EmailMaker", "Mailbox", "Folder", FolderCombo
SaveSetting "EmailMaker", "Mailbox", "From", FromText
SaveSetting "EmailMaker", "Secondary", "On", SecondaryOption
SaveSetting "EmailMaker", "Secondary", "Field", SecondFieldCombo.Text

注释:-- Reinitialize the main form
MDIMain.Initialize

注释:-- Disable the Apply button
cmdApply.Enabled = False
End Sub



  以下是ADODB FIELDS 代码:


Private Sub FillFolderCombo()
On Error GoTo Err_Folder
注释: 注释:Put the names of all available folders in the folderCombo

Dim myOlApp As Object
Dim olNamespace As Object
Dim iCount As Integer
Dim mystr As String


Set myOlApp = CreateObject("Outlook.Application")
Set olNamespace = myOlApp.GetNameSpace("MAPI")

iCount = 1
FolderCombo.Clear
mystr = MailboxCombo

While iCount <= olNamespace.folders(mystr).folders.Count
FolderCombo.AddItem olNamespace.folders(mystr).folders(iCount).Name
iCount = iCount + 1
Wend

Exit Sub
Err_Folder:
MsgBox "Unable to resolve mailbox"
End Sub




Private Sub FillMailboxCombo()
注释:--Fill in all the names of available mailboxes

Dim myOlApp As Object
Dim olNamespace As Object
Dim iCount As Integer

Set myOlApp = CreateObject("Outlook.Application")
Set olNamespace = myOlApp.GetNameSpace("MAPI")

iCount = 1
MailboxCombo.Clear
While iCount <= olNamespace.folders.Count
MailboxCombo.AddItem olNamespace.folders(iCount).Name
iCount = iCount + 1
Wend
End Sub


  代码:

Private Sub FillFolderCombo()
On Error GoTo Err_Folder
注释: 注释:Put the names of all available folders in the folderCombo

Dim myOlApp As Object
Dim olNamespace As Object
Dim iCount As Integer
Dim mystr As String


Set myOlApp = CreateObject("Outlook.Application")
Set olNamespace = myOlApp.GetNameSpace("MAPI")

iCount = 1
FolderCombo.Clear
mystr = MailboxCombo

While iCount <= olNamespace.folders(mystr).folders.Count
FolderCombo.AddItem olNamespace.folders(mystr).folders(iCount).Name
iCount = iCount + 1
Wend

Exit Sub
Err_Folder:
MsgBox "Unable to resolve mailbox"
End Sub




Private Sub FillMailboxCombo()
注释:--Fill in all the names of available mailboxes

Dim myOlApp As Object
Dim olNamespace As Object
Dim iCount As Integer

Set myOlApp = CreateObject("Outlook.Application")
Set olNamespace = myOlApp.GetNameSpace("MAPI")

iCount = 1
MailboxCombo.Clear
While iCount <= olNamespace.folders.Count
MailboxCombo.AddItem olNamespace.folders(iCount).Name
iCount = iCount + 1
Wend
End Sub


  在此程序里,我创建了Message Properties对话框,以便让用户可以创建或修改"from" field。虽然我没有找出一个行之有效的办法来增加所有有效的地址选择,但是,Sent From的设置在Message Properties 对话框里也是一个可进入的域。

  在Message Editing窗口里有个比较奇怪的现象。当在Message Editing窗口内找开一个message时,窗口的图标会是一个合上的信封。当修改或编辑message旱,图标则会变成有支笔放在信封上的图案。然后,当保存时,图标又会变成合上的信封。这项功能帮助用户了解到是不是自上一次编辑以来对文件有所保存。这个功能运行稳定,除了当Message Editing窗口最大化时。当窗口最大化时,图标则不会改变,我也没有找出为什么会发生这种现象的源由。