outlook插件 邮件群发系统 outlook添加按钮 outlook添加窗口

界面

 

thisoutlooksession

  1. '-

 

  1. ---------------
  2. Option Explicit
  3. 'Private WithEvents olOutboxItems As Items
  4. '----------------
  5. 'Private WithEvents Importbtn As Office.CommandBarButton
  6. Private WithEvents SendMailbtn As Office.CommandBarButton
  7. Public WithEvents myControl As Office.CommandBarButton
  8. '----------------
  9. Dim objNS As NameSpace
  10. '----------------
  11. Dim MailAddFile As String
  12. 'Added by Zheng
  13. Public Flag As Boolean
  14. Public WithEvents myItem As mailItem
  15. Public WithEvents colInsp As Outlook.Inspectors
  16. Public WithEvents colCustomersItems As Outlook.Items
  17. Public WithEvents olInboxItems As Outlook.Items
  18. Public tempFolder As Outlook.MAPIFolder
  19. Dim emailReg As String
  20. Private Sub Application_Quit()
  21.   '----------------
  22. '  Set olOutboxItems = Nothing
  23. '  Set objNS = Nothing
  24.   '----------------
  25.   
  26. End Sub
  27. Private Sub Application_Startup()
  28.   '----------------
  29.   emailReg = "[A-Za-z0-9_]+[A-Za-z0-9_/-]*(/.[A-Za-z0-9_]+[A-Za-z0-9_/-]*)*@[A-Za-z0-9_]+[A-Za-z0-9_/-]*(/.[A-Za-z0-9_]+[A-Za-z0-9_/-]*)*/.[A-Za-z]{2,6}"
  30.   Set objNS = Application.GetNamespace("MAPI")
  31. '  Set olOutboxItems = objNS.GetDefaultFolder(olFolderOutbox).Items
  32.   Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
  33.   '----------------
  34.   'MailAddFile = "c:/YiFanMu/MailSys/MailAddress.xls"
  35.   'Call CreateFile(MailAddFile)
  36.   
  37.   Call CreateFile("C:/YiFanMu/MailSys/Templates/")
  38.   
  39.   Dim oExplorer As Outlook.Explorer
  40.   Set oExplorer = Application.ActiveExplorer
  41.   'Set Importbtn = CreateCommandBarButton(oExplorer.CommandBars, "导入收件人地址 ")
  42.   Set SendMailbtn = CreateCommandBarButton(oExplorer.CommandBars, "邮件群发")
  43. End Sub
  44. 'Private Sub Importbtn_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
  45. '  MsgBox "Click: " & Ctrl.Caption
  46. 'End Sub
  47. Private Sub SendMailbtn_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
  48.   UserForm1.Show
  49. End Sub
  50. Public Function CreateCommandBarButton(oBars As Office.CommandBars, str As StringAs Office.CommandBarButton
  51.   On Error Resume Next
  52.   Dim oMenu As Office.CommandBar
  53.   Dim oBtn As Office.CommandBarButton
  54.   Set oMenu = oBars(str)
  55.   If oMenu Is Nothing Then
  56.     Set oMenu = oBars.Add(str, msoBarTop, , True)
  57.     Set oBtn = oMenu.Controls.Add(msoControlButton, , str, , True)
  58.     oBtn.Caption = str
  59.     oBtn.Tag = str
  60.     oBtn.FaceId = 1130
  61.   Else
  62.     Set oBtn = oMenu.FindControl(, , str)
  63.     If oBtn Is Nothing Then
  64.       Set oBtn = oMenu.Controls.Add(msoControlButton, , str, , True)
  65.       oBtn.Caption = str
  66.       oBtn.Tag = str
  67.     End If
  68.   End If
  69.   oMenu.Visible = True
  70.   Set CreateCommandBarButton = oBtn
  71. End Function
  72. Public Sub CreateFile(sFilePath)
  73.     Dim oFSO As Object
  74.     Dim nPosition As Integer
  75.     nPosition = InStr(1, sFilePath, "/", 0)
  76.     Set oFSO = CreateObject("Scripting.FileSystemObject")
  77.     While (nPosition <> 0)
  78.         If (Not oFSO.FolderExists(Mid(sFilePath, 1, nPosition))) Then
  79.             oFSO.CreateFolder (Mid(sFilePath, 1, nPosition))
  80.         End If
  81.         nPosition = InStr(nPosition + 1, sFilePath, "/", 0)
  82.     Wend
  83. '    If (Not oFSO.FileExists(sFilePath)) Then
  84. '        oFSO.CreateTextFile (sFilePath)
  85. '    End If
  86.     Set oFSO = Nothing
  87. End Sub
  88. 'Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  89. '    Dim NewMailItem As Outlook.mailItem
  90. '    Dim count As Long
  91. '    count = Item.Recipients.count
  92. '    If count > 1 Then
  93. '        Cancel = False
  94. '        Set NewMailItem = Item
  95.         'NewMailItem.GetInspector.Close olDiscard
  96.         'Call createTempFolder
  97.         'MsgBox (tempFolder)
  98.         'Item.Move (tempFolder)
  99. '    End If
  100. ''On Error Resume Next
  101. '    If Item.Class = olMail Then
  102. '        If Item.Recipients.count <> 1 Then
  103. '            For i = 1 To Item.Recipients.count
  104. '                Set NewMailItem = Item.Copy
  105. '                For j = NewMailItem.Recipients.count To 1 Step -1
  106. '                    NewMailItem.Recipients.Remove (j)
  107. '                Next
  108. '                NewMailItem.Recipients.Add (Item.Recipients.Item(i))
  109. '                NewMailItem.Send
  110. '            Next
  111. 'NewMailItem.se
  112. '            Item.Close olSave
  113. '        End If
  114. '    End If
  115. 'End Sub
  116. 'Private Sub createTempFolder()
  117. '    Dim mpfRoot As Outlook.MAPIFolder
  118. '    Dim mpf As Outlook.MAPIFolder
  119. '    Dim isTempExist As Boolean
  120. '    isTempExist = False
  121. '    Set mpf = Application.Session.GetDefaultFolder(olFolderInbox)
  122. '    Set mpfRoot = mpf.Parent
  123. '    Dim eachFolder As MAPIFolder
  124. '    Dim x As MAPIFolder
  125. '    For Each x In mpfRoot.Folders
  126. '        If x.Name = "temp" Then
  127. '            isTempExist = True
  128. '            Set tempFolder = x
  129. '            Exit For
  130. '        End If
  131. '    Next x
  132. '    If Not isTempExist Then
  133. '        Set tempFolder = mpfRoot.Folders.Add("temp")
  134. '    End If
  135. 'End Sub
  136. 'Private Sub removeTempFolder()
  137. '    Dim mpfRoot As Outlook.MAPIFolder
  138. '    Dim mpf As Outlook.MAPIFolder
  139. '    Dim isTempExist As Boolean
  140. '    isTempExist = False
  141. '    Set mpf = Application.Session.GetDefaultFolder(olFolderInbox)
  142. '    Set mpfRoot = mpf.Parent
  143. '    Dim eachFolder As MAPIFolder
  144. '    Dim x As MAPIFolder
  145. '    For Each x In mpfRoot.Folders
  146. '        If x.Name = "temp" Then
  147. '            x.Delete
  148. '            Exit For
  149. '        End If
  150. '    Next x
  151. 'End Sub
  152. 'Private Sub olOutboxItems_ItemAdd(ByVal Item As Object)
  153. 'Dim myReply As Outlook.mailItem
  154. 'Dim i, j As Integer
  155. 'On Error Resume Next
  156. '    If Item.Class = olMail And Not TypeName(Item) = "Nothing" Then
  157. '        If Item.Recipients.count > 1 Then
  158. '            For i = 1 To Item.Recipients.count
  159. '                Set myReply = Item.Copy
  160. '                If Not TypeName(myReply) = "Nothing" Then
  161. '                    For j = myReply.Recipients.count To 1 Step -1
  162. '                        myReply.Recipients.Remove (j)
  163. '                    Next
  164. '                    myReply.Recipients.Add (Item.Recipients.Item(i))
  165. '                    myReply.Send
  166. '                End If
  167. '            Next
  168. '            Set myReply = Nothing
  169. '            Item.Delete
  170. '        End If
  171. '        Set Item = Nothing
  172. '    End If
  173. 'End Sub
  174. Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
  175. '    Dim subj As String
  176. '    Dim senderName As String
  177. '    Dim senderAddr As String
  178. '    Dim body As String
  179. '    Dim regExp As regExp
  180. '    Dim matches As Object
  181. '    Dim failedAddr As String
  182. '    If typeName(Item) = "MailItem" Then
  183. '        subj = Item.subject
  184. '        senderName = Item.senderName
  185. '        senderAddr = Item.SenderEmailAddress
  186. '        If senderName = "Mail Delivery System" And (senderAddr = "MAILER-DAEMON@sina.com" Or senderAddr = "MAILER-DAEMON@smtp.sina.com.cn") Then
  187. '            body = Item.body
  188. '            Set regExp = New regExp
  189. '            regExp.Pattern = emailReg
  190. '            Set matches = regExp.Execute(body)
  191. '            If matches.count >= 0 Then
  192. '                failedAddr = matches(0).Value
  193. '                If senderAddr = "MAILER-DAEMON@sina.com" Then
  194. '                    Call logEmailNotFound(failedAddr)
  195. '                End If
  196. '                If senderAddr = "MAILER-DAEMON@smtp.sina.com.cn" Then
  197. '                    Call logEmailNotSent(failedAddr)
  198. '                End If
  199. '                Item.Close olDiscard
  200. '                Item.Delete
  201. '            End If
  202. '        End If
  203. '    End If
  204. End Sub
  205. Private Sub log(file As String, msg As String)
  206.     Dim now
  207.     now = "[" & Date & " " & Time & "] "
  208.     Open file For Append As #1
  209.     Print #1, now & msg
  210.     Close #1
  211. End Sub
  212. Private Sub logInvalidEmail(email As String)
  213.     Call log("c:/YiFanMu/MailSys/bademail.log""邮件地址错误: " & email)
  214. End Sub
  215. Private Sub logEmailNotFound(email As String)
  216.     Call log("c:/YiFanMu/MailSys/notfound.log""邮件地址未找到: " & email)
  217. End Sub
  218. Private Sub logEmailNotSent(email As String)
  219.     Call log("c:/YiFanMu/MailSys/failed.log""邮件发送失败: " & email)
  220. End Sub
  221. Public Sub clearBadMail()
  222.     Dim objMAPIFolder As MAPIFolder
  223.     Dim totalNumber As Long
  224.     Dim i As Integer
  225.     Dim objMailItem As mailItem
  226.     Set objMAPIFolder = Application.Session.GetDefaultFolder(FolderType:=olFolderDeletedItems)
  227.     totalNumber = objMAPIFolder.Items.count
  228.     If totalNumber >= 1 Then
  229.         For i = totalNumber To 1 Step -1                         '   清除已删除邮件中邮件!
  230.             '                 DoEvents
  231.             Set objMailItem = objMAPIFolder.Items(i)
  232.             If Left(objMailItem.subject, 8) = "BADADDR_" Then
  233.                 objMailItem.Close olDiscard
  234.                 objMailItem.Delete
  235.             End If
  236.         Next i
  237.     End If
  238. End Sub
  239. Private Sub myControl_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
  240.     Dim NewMailItem As Outlook.mailItem, Item As Outlook.mailItem, tmpMailItem As Outlook.mailItem
  241.     Dim i, j, k As Integer
  242.     Dim count As Long
  243.     Dim tempAddr As String
  244.     Dim reg As regExp
  245.     Set reg = New regExp
  246.     reg.Pattern = "^" & emailReg & "$"
  247.     i = 0
  248.     j = 0
  249.     k = 0
  250.     Dim arr() As String
  251.     Dim rec As Recipient
  252.     Dim validAddrs() As String
  253.     Dim temp As String
  254.     Dim addrLen As Long
  255.     
  256.     If Application.ActiveInspector.CurrentItem.Class = olMail Then
  257.         Set Item = Application.ActiveInspector.CurrentItem.Copy
  258.         Application.ActiveInspector.CurrentItem.Close olDiscard
  259.         If Item.Recipients.count <> 1 Then
  260.         
  261.             addrLen = -1
  262.             count = Item.Recipients.count
  263.             For i = count To 1 Step -1
  264.                 temp = Item.Recipients.Item(i)
  265. '                arr = Split(temp, "<")
  266. '                If UBound(arr) > 0 Then
  267. '                    tempAddr = Left(arr(1), Len(arr(1)) - 1)
  268. '                Else
  269.                     tempAddr = temp
  270. '                End If
  271. '                MsgBox (tempAddr)
  272.                 If reg.test(tempAddr) Then
  273.                     addrLen = addrLen + 1
  274.                 Else
  275.                     Call logInvalidEmail(tempAddr)
  276.                     Item.Recipients.Remove (i)
  277.                 End If
  278.             Next i
  279.             If addrLen >= 0 Then
  280.                 ReDim validAddrs(addrLen)
  281.                 count = Item.Recipients.count
  282.                 For i = 1 To Item.Recipients.count
  283.                     temp = Item.Recipients.Item(i)
  284.                     arr = Split(temp, "<")
  285.                     If UBound(arr) > 0 Then
  286.                         tempAddr = Left(arr(1), Len(arr(1)) - 1)
  287.                     Else
  288.                         tempAddr = temp
  289.                     End If
  290.                     validAddrs(i - 1) = tempAddr
  291.                 Next i
  292.     
  293.                 For j = Item.Recipients.count To 1 Step -1
  294.                     Item.Recipients.Remove (j)
  295.                 Next j
  296.                 
  297.                 If addrLen > 0 Then
  298. '                    tmpMailItem = Item.Copy
  299. '                    For j = tmpMailItem.Recipients.count To 1 Step -1
  300. '                        tmpMailItem.Recipients.Remove (j)
  301. '                    Next j
  302.                     For i = LBound(validAddrs) To UBound(validAddrs)
  303.                         tempAddr = validAddrs(i)
  304.                         If i < UBound(validAddrs) Then
  305.                             Set NewMailItem = Item.Copy
  306.                         Else
  307.                             Set NewMailItem = Item
  308.                         End If
  309.                         NewMailItem.Recipients.Add (tempAddr)
  310.                         NewMailItem.Send
  311.                     Next i
  312.                 Else
  313.                     Item.Close olDiscard
  314.                     Item.Delete
  315.                 End If
  316.                 Set NewMailItem = Nothing
  317.             Else
  318.                 Item.Close olDiscard
  319.                 Item.Delete
  320.             End If
  321.             Set Item = Nothing
  322.         End If
  323.     End If
  324. End Sub

 

userform1

  1. Dim templatePath As String
  2. Private Sub DeselectAllbtn_Click()
  3.     Dim count As Long
  4.     count = MailAdrtrv.Nodes.count
  5.     For i = 1 To count
  6.         MailAdrtrv.Nodes.Item(i).Checked = False
  7.     Next
  8. End Sub
  9. Private Sub SelectAllbtn_Click()
  10.     Dim count As Long
  11.     count = MailAdrtrv.Nodes.count
  12.     For i = 1 To count
  13.         MailAdrtrv.Nodes.Item(i).Checked = True
  14.     Next
  15. End Sub
  16. Private Sub UserForm_Initialize()
  17.     Dim strnode As String
  18.     Dim tvnode As node
  19.     Dim i, j As Long
  20.     Dim FSO As Object
  21.     Dim TemplateOptionbtn ' As OptionButton
  22.     Dim TemplateOptionbtnCount As Integer
  23.     
  24.     With Me.Frame2
  25.         'This will create a vertical scrollbar
  26.         .ScrollBars = fmScrollBarsVertical
  27.         'Change the values of 2 as Permission your requirements
  28.         .ScrollHeight = .InsideHeight * 2
  29.         .ScrollWidth = .InsideWidth * 9
  30.     End With
  31.    
  32.     templatePath = "C:/YiFanMu/MailSys/Templates"
  33.     MailAddFile = "c:/YiFanMu/MailSys/MailAddress.xls"
  34.     
  35.     MailAdrtrv.Nodes.Clear
  36.     i = 0
  37.     j = 0
  38.     ' RETRIEVE DATA FROM FILE
  39.     ' Open file for input.
  40. '    Open MailAddFile For Input As #1
  41.     ' Loop until the end of file is reached.
  42. '    Do While Not EOF(1)
  43.     ' Read data into variables.
  44. '    i = i + 1
  45. '    Input #1, strnode
  46. '    If InStr(1, strnode, "@") = 0 Then
  47. '        j = i
  48. '        Set tvnode = MailAdrtrv.Nodes.Add(, , , strnode)
  49. '    Else
  50. '        Set tvnode = MailAdrtrv.Nodes.Add(j, tvwChild, , strnode)
  51. '    End If
  52. '    Loop
  53. '    ' Close file.
  54. '    Close #1
  55.     
  56.     Dim xlApp As Excel.Application
  57.     Dim xlWb As Excel.Workbook
  58.     Dim xlWs As Excel.Worksheet
  59.     Dim Rng As Excel.Range
  60.     Dim typeName As String
  61.     Dim clientName As String
  62.     Dim email As String
  63. '    Dim newEmail As String
  64.     Dim rowCount As Long
  65.     Dim currentTypeId As Long
  66.     Dim parentId As Long
  67.     currentTypeId = 0
  68.     parentId = 0
  69.     
  70.     Dim arra() As String
  71.     Dim eachAddr As String
  72.     
  73.     Set xlApp = ThisOutlookSession.CreateObject("Excel.Application")
  74.     Set xlWb = xlApp.Workbooks.Open(CStr(MailAddFile))
  75.     
  76.     For Each xlWs In xlWb.Worksheets
  77.         typeName = xlWs.name
  78.         'add the parent node here
  79.         Set tvnode = MailAdrtrv.Nodes.Add(, , , typeName)
  80.         currentTypeId = currentTypeId + 1
  81.         parentId = currentTypeId
  82.         Set Rng = xlWs.Range("A1")
  83.         rowCount = Rng.Cells(xlWs.Rows.count, 1).End(xlUp).Row
  84.         For i = 2 To rowCount Step 1
  85.             clientName = xlWs.Cells(i, 3).Value
  86.             email = xlWs.Cells(i, 5).Value
  87.             
  88.             arra = Split(email, "/")
  89.             For j = LBound(arra) To UBound(arra)
  90.                 
  91. '            newEmail = xlWs.Cells(i, 6).Value
  92. '            If newEmail <> "" Then
  93. '                email = newEmail
  94. '            End If
  95.                 If arra(j) <> "" Then
  96.     '                MsgBox (typeName & ": " & clientName & "(" & email & ")")
  97.                     'add child node here
  98.                     Set tvnode = MailAdrtrv.Nodes.Add(parentId, tvwChild, , clientName & "<" & arra(j) & ">")
  99.                     currentTypeId = currentTypeId + 1
  100.                 End If
  101.             Next
  102.         Next i
  103.     Next xlWs
  104.     
  105.     xlWb.Close (False)
  106.     Set Rng = Nothing
  107.     Set xlWs = Nothing
  108.     Set xlWb = Nothing
  109.     Set xlApp = Nothing
  110.     
  111.     Set FSO = CreateObject("Scripting.FileSystemObject")
  112.     TemplateOptionbtnCount = 0
  113.     Dim fFile As Object
  114.     Dim fPatten As String
  115.     Dim w1 As String
  116.     fPatten = "oft"
  117.     w1 = ""
  118.     For Each fFile In FSO.GetFolder(templatePath).Files
  119.         If UCase$(fPatten) = UCase$(FSO.GetExtensionName(fFile.Path)) Then
  120.             'MsgBox (fFile.Name)
  121.             TemplateOptionbtnCount = TemplateOptionbtnCount + 1
  122.             
  123.              Set TemplateOptionbtn = Me.Frame2.Controls.Add("Forms.OptionButton.1", , True)
  124.              With TemplateOptionbtn
  125.                 .Caption = Mid(fFile.name, 1, InStr(1, fFile.name, ".oft") - 1)
  126.                 .Top = 8 + (TemplateOptionbtnCount - 1) * 15
  127.                 .Left = 8
  128.                 .Height = 15
  129.              End With
  130.         End If
  131.     Next
  132.     Set FSO = Nothing
  133. End Sub
  134. Private Sub WriteMailbtn_Click()
  135.     Dim selectItem 'As OptionButton
  136.     Dim NewMailItem As Outlook.mailItem
  137.     Dim tempSelected As Boolean
  138.     tempSelected = False
  139.      
  140.     UserForm1.Hide
  141.     For Each x In Me.Frame2.Controls
  142.         If x.Value = True Then
  143.             Set selectItem = x
  144.             tempSelected = True
  145.             Exit For
  146.         End If
  147.     Next
  148.     
  149.     If tempSelected Then 'modified by zheng
  150.         Set NewMailItem = Application.CreateItemFromTemplate(templatePath & "/" & selectItem.Caption & ".oft")
  151.         Call SetReceiveMailAdd(NewMailItem, MailAdrtrv)
  152.     Else
  153.         Set NewMailItem = Application.CreateItem(olMailItem)
  154.         Call SetReceiveMailAdd(NewMailItem, MailAdrtrv)
  155.     End If
  156.     NewMailItem.Display
  157.     Dim oExplorer As Outlook.Inspector
  158.     Set oExplorer = NewMailItem.GetInspector
  159.     Set ThisOutlookSession.myControl = ThisOutlookSession.CreateCommandBarButton(oExplorer.CommandBars, "邮件群发发送 ")
  160. End Sub
  161. Private Sub SetReceiveMailAdd(mailItem, tvHandle)
  162.     'Added by Zheng
  163.     Dim email As String
  164.     Dim count As Long
  165.     Dim tempAddr As String
  166.     Dim arr() As String
  167.     
  168.     For i = mailItem.Recipients.count To 1 Step -1 'modified by zheng
  169.         mailItem.Recipients.Remove (i)
  170.     Next
  171.     
  172.     count = MailAdrtrv.Nodes.count
  173.     For i = 1 To count
  174.         If MailAdrtrv.Nodes.Item(i).Checked Then
  175.             email = MailAdrtrv.Nodes.Item(i)
  176.             If InStr(1, email, "<") <> 0 Then
  177.                 arr = Split(email, "<")
  178.                 If UBound(arr) > 0 Then
  179.                     tempAddr = Left(arr(1), Len(arr(1)) - 1)
  180.                 Else
  181.                     tempAddr = email
  182.                 End If
  183.                 mailItem.Recipients.Add (tempAddr)
  184.             End If
  185.         End If
  186.        
  187.     Next
  188.   
  189. End Sub
  190. 'Added by Zheng
  191. Private Sub MailAdrtrv_NodeCheck(ByVal node As MSComctlLib.node)
  192.   Dim id As Long
  193.   Dim isChecked As Boolean
  194.   id = node.Index
  195.   isChecked = node.Checked
  196.   Dim i As Long
  197.   Dim count As Long
  198.   Dim email As String
  199.   count = MailAdrtrv.Nodes.count
  200.   If InStr(1, node, "<") = 0 Then
  201.      For i = id + 1 To count
  202.         email = MailAdrtrv.Nodes.Item(i)
  203.         If InStr(1, email, "<") = 0 Then
  204.             Exit For
  205.         Else
  206.             MailAdrtrv.Nodes.Item(i).Checked = isChecked
  207.         End If
  208.      Next
  209.   End If
  210.   
  211. End Sub
  212. Sub EnumCommandBars()
  213.     Dim objOL As Outlook.Application
  214.     Dim objNS As Outlook.NameSpace
  215.     Dim objDrafts As Outlook.MAPIFolder
  216.     Dim objPost As Outlook.PostItem
  217.     Dim colCB As Office.CommandBars
  218.     Dim objCB As Office.CommandBar
  219.     Dim strWindow As String
  220.     Dim strExplBars As String
  221.     Dim strInspBars As String
  222.     Dim strText As String
  223.     Dim arrBars() As String
  224.     Dim i As Integer
  225.     On Error Resume Next
  226.     Set objOL = Application
  227.     Set objNS = objOL.Session
  228.     Set objDrafts = objNS.GetDefaultFolder(olFolderDrafts)
  229.     strExplBars = "Menu Bar,Standard,Advanced,Web"
  230.     strInspBars = "Menu Bar,Standard,Form Design,Formatting"
  231.     strWindow = typeName(objOL.ActiveWindow)
  232.     Select Case strWindow
  233.         Case "Explorer"
  234.             Set colCB = objOL.ActiveExplorer.CommandBars
  235.             arrBars = Split(strExplBars, ",")
  236.         Case "Inspector"
  237.             Set colCB = objOL.ActiveInspector.CommandBars
  238.             arrBars = Split(strInspBars, ",")
  239.     End Select
  240.     If Not colCB Is Nothing Then
  241.         Set objPost = objDrafts.Items.Add("IPM.Post")
  242.         objPost.subject = "CommandBars for " & strWindow & _
  243.                           ": " & colCB.Parent.Caption
  244.         objPost.BodyFormat = olFormatPlain
  245.         For i = 0 To UBound(arrBars)
  246.             Set objCB = colCB.Item(arrBars(i))
  247.             Call EnumOneBar(objCB, strText)
  248.             strText = strText & vbCrLf & "===========" & vbCrLf
  249.         Next
  250.         objPost.body = Mid(strText, 5)
  251.         objPost.Save
  252.         objPost.Display
  253.     End If
  254.     Set objOL = Nothing
  255.     Set objNS = Nothing
  256.     Set objDrafts = Nothing
  257.     Set objPost = Nothing
  258.     Set colCB = Nothing
  259.     Set objCB = Nothing
  260. End Sub
  261. Sub EnumOneBar(cb As Office.CommandBar, ByRef postText)
  262.     Dim objControl As Office.CommandBarControl
  263.     Dim objPopupControl As Office.CommandBarPopup
  264.     postText = postText & vbCrLf & vbCrLf & "CommandBar: " & cb.name
  265.     For Each objControl In cb.Controls
  266.         If objControl.BuiltIn = True Then
  267.             Select Case objControl.Type
  268.                 Case msoControlPopup, _
  269.                      msoControlButtonPopup, _
  270.                      msoControlGraphicPopup, _
  271.                      msoControlSplitButtonPopup
  272.                     postText = postText & vbCrLf & vbCrLf & _
  273.                       objControl.Caption & _
  274.                       " (Submenu) - " & objControl.id
  275.                     Set objPopupControl = objControl
  276.                     If objControl.id = 5577 Then
  277.                         MsgBox "ss"
  278.                     End If
  279.                     Call EnumOneBar( _
  280.                       objPopupControl.CommandBar, postText)
  281.                  Case Else
  282.                     postText = postText & vbCrLf & vbTab & _
  283.                       objControl.Caption & " - " & objControl.id
  284.                     If objControl.id = 5577 Then
  285.                         MsgBox "ss"
  286.                     End If
  287.             End Select
  288.         End If
  289.     Next
  290.     Set objControl = Nothing
  291.     Set objPopupControl = Nothing
  292. End Sub
  293. Sub FindSendBtn(cb As Office.CommandBar)
  294.     Dim objControl As Office.CommandBarControl
  295.     Dim objPopupControl As Office.CommandBarPopup
  296.     For Each objControl In cb.Controls
  297.         If objControl.BuiltIn = True Then
  298.             Select Case objControl.Type
  299.                 Case msoControlPopup, _
  300.                      msoControlButtonPopup, _
  301.                      msoControlGraphicPopup, _
  302.                      msoControlSplitButtonPopup
  303.                     Set objPopupControl = objControl
  304.                     If objControl.id = 5577 Then
  305.                         objControl.Visible = False
  306.                     End If
  307.                     Call FindSendBtn(objPopupControl.CommandBar)
  308.                  Case Else
  309.                     If objControl.id = 5577 Then
  310.                         objControl.Visible = False
  311.                     End If
  312.             End Select
  313.         End If
  314.     Next
  315.     Set objControl = Nothing
  316.     Set objPopupControl = Nothing
  317. End Sub

全部代码也可以从http://download.csdn.net/source/643389下载

 

Mail2MO(Mail to Mobile)是针对各类邮件客户端(如Outlook等)开发的插件类短信产品。用户下载安装免费插件,就可在Outlook上同时收发邮件和短信,同时利用Outlook的通讯簿协同管理联系人的邮件地址和手机号码,从而提高信息处理效率。 Mail2MO-OL2MO是Outlook的短信插件 1、 短信功能:用户可在Outlook上,与新邮件基本完全相同的界面下进行文字录入,电话号码的选择,发出等操作,从而以邮件的方式发送短信。 2、 邮件提醒短信功能:Mail2MO在新邮件界面下增加一个“邮件提醒&rdquo;按钮,用户在发送邮件前,按下此按钮系统将自动把邮件题目自动发送至收件人的手机上,提醒其查收邮件。 3、 通讯簿管理手机号码功能:用户可通过Outlook中的通讯簿对手机号码进行储存,管理及使用,使其可以同时管理邮件地址及手机号码。 4、 同步回复功能:本产品具有同步回复功能,接收人收到通过此服务发出的短信后,可同时直接回复至发出人的邮箱和手机上,收到回复短信和邮件均免费。 5、 短信群发功能:使用此服务,可同时发给上千个手机用户。 6、 短信可保存在邮件客户端上:通过此产品发送和接收的信息将保存在邮件客户端的“已发送邮件&rdquo;和“收件箱&rdquo;中,方便用户反复使用和查找,同时可将短信内容的保存转移至邮件客户端上。 7、 分组发送功能:本产品可根据用户在通讯簿中的分组,按组发送短信。 8、 定时发送功能:本产品可以定时发送短信,如生日祝福,节日祝福等。 9、 可支持长短信的发送:本产品可支持10条长度(700字符)的短信发送 10、 显示发短信人的手机号码:如果用户的手机已经被保存在对方的手机中,那么通过此服务发出的短信,在接受者的手机上一般显示为发送者的姓名,而非陌生的号码。 11、 不受任何网关限制:本服务使用邮件端口发送信息,只要用户可以发送邮件就可以使用本服务,不需修改防火墙的端口设置,可以穿越所有的防火墙或者NAT。 12、 以同等价格发跨国短信:由于本服务是通过邮件的方式发送短信的,所以只要在中国大陆地区开通了本服务,无论用户身在何处,都可以以同等价格在境外向国内用户发送短信,并可收到回复。 13、 *注:服务使用说明:如用户需开通本服务,下载安装插件后,需用手机进行注册,注册方式如下。资费标准:约6分/条短信。 注册后用户将收到6位服务密码,将开通服务的手机号码和服务密码填入程序的“设置&rdquo;栏中,即可使用本服务。 注册方式 Mail2MO经济套餐:5元包月,含80条短信 移动用户:发送 FSJ 至 628971 联通用户:发送 5501 至 928971 注:联通用户收到第一条提示短信后,需重新发送 5501 到 928971,请勿直接回复! Mail2MO商务套餐:10元/月,含180条短信 移动用户:发送 JSJ 至 628971 联通用户:发送 5503 至 928971 注:联通用户收到第一条提示短信后,需重新发送 5503 到 928971,请勿直接回复! 客服热线:010-88255550
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值