Foxtable(狐表)用户栏目专家坐堂 → vb.net 代码转换请教


  共有1907人关注过本帖树形打印复制链接

主题:vb.net 代码转换请教

帅哥哟,离线,有人找我吗?
ljh29206
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1368 积分:12195 威望:0 精华:0 注册:2012/3/5 11:32:00
vb.net 代码转换请教  发帖心情 Post By:2024/6/28 11:44:00 [显示全部帖子]

以下 为 代码  从 c# 转换到 vb.net

如何把 该内容 变为  foxtable 可用的全局代码 求指点 ,谢谢 老板

Imports System
Imports System.Linq
Imports Microsoft.Office.Interop.Outlook
Imports System.Collections.Generic

Namespace EmailReceiver
    Class Program
        Shared outlookApp As ApplicationClass = New Microsoft.Office.Interop.Outlook.ApplicationClass()
        Shared ns As [NameSpace]

        Private Shared Sub Main(ByVal args As String())
            Console.WriteLine("start to monitor new emails")
            ns = outlookApp.GetNamespace("MAPI")
            outlookApp.NewMailEx += New ApplicationEvents_11_NewMailExEventHandler(AddressOf outlookApp_NewMailEx)
            outlookApp.NewMail += New ApplicationEvents_11_NewMailEventHandler(AddressOf outlookApp_NewMail)

            While True
            End While
        End Sub

        Private Shared Sub outlookApp_NewMail()
            Console.WriteLine("a new message comes: new email")
        End Sub

        Private Shared Sub outlookApp_NewMailEx(ByVal EntryIDCollection As String)
            Console.WriteLine("a new message comes")
            AnalyzeNewItem(EntryIDCollection)
        End Sub

        Private Shared Sub AnalyzeNewItem(ByVal entry As String)
            Dim inbox = ns.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
            Dim allmails As List(Of MailItem) = New List(Of MailItem)()

            For Each item In inbox.Items

                If TypeOf item Is MailItem Then
                    Dim mail = TryCast(item, MailItem)
                    allmails.Add(mail)
                End If
            Next

            Dim latest = allmails.Max(Function(s) s.ReceivedTime)
            Dim latestMailItem = allmails.FirstOrDefault(Function(s) s.ReceivedTime = latest)

            If latestMailItem IsNot Nothing Then
                Console.WriteLine(latestMailItem.Subject)
                Console.WriteLine(latestMailItem.[To])
                Console.WriteLine(latestMailItem.SenderName)
                Console.WriteLine(latestMailItem.ReceivedTime)
                Console.WriteLine(latestMailItem.Body)
            End If
        End Sub
    End Class
End Namespace

 回到顶部
帅哥哟,离线,有人找我吗?
ljh29206
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1368 积分:12195 威望:0 精华:0 注册:2012/3/5 11:32:00
  发帖心情 Post By:2024/6/28 15:03:00 [显示全部帖子]

这个代码 是 已经从 c# 转换为 vb 的了

篮板  我用 你的代码 放进去  全局代码 里面 

会提示   未定义  name space

sheared ns as [namespace]

可否帮忙再看看呢 ,  foxtable 可以这样定义命名空间的?  不懂怎么搞 求助

 回到顶部