你们都一直这么乐于助人,我不知道是否我可能会麻烦你多一点。 我已经接近完成我对VBA转换从VB.net用于Outlook,为了完成这一点,我需要的究竟是什么特定的代码片返回的一些信息。 如果你都可以帮忙与,问题可能消失; 如果没有,我可能需要对这个无效预选赛错误一些帮助。
据我了解,我宣布在VBA的“数组”像这样的命令:
Dim Computers(1, 1) As String
其产生的2×2阵列。 然后我尝试填补这样的:
Computers.Add ComputerName, ErrorState
其中计算机和ErrorState是,我已经充满变数。 这将导致错误。 我会为你提供下面的整个相关部分。 我需要知道相关项目有多少是在Outlook收件箱,如果他们今天的日期,并通过正确的发送者发送,这意味着检查。 我需要这一点是为了获得在阵列计算机正确的尺寸。 (数组被填充,现在我知道了正确的尺寸,但在实践中我不会。)我拿了一块的代码,我通过谷歌,脚本字典输出发现,但我不完全理解。 我需要电子邮件的只是数字,没有任何不相关的文字,我希望,调试线将能告诉我哪一个命令,我需要返回数字而已。 不幸的是,由于上述错误的,我不能让这条线。 即使通过分步执行代码,它告诉我的第一件事是,有一个问题就在这里。 整个相关部分如下。 我知道该格式是有问题的,但我只用VB.NET工作4天,这是我用VBA工作的第二天,所以我不太有一切下来了。 有一个在这里一些无关痛痒的东西,我敢肯定,但我没有经验,使东西是相关还是不来电,所以我离开了这一切。 很抱歉的长度!
Private Sub Main()
Dim objOutlook As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim strDate As String
Dim ComputerName As Object
Dim ErrorState As Object
Dim DateToday As String: DateToday = Format(Date, "yyyy/MM/dd")
Dim SenderEmail As String
Dim Computers(1, 1) As String
Dim compLength As Integer
Dim disabledList As Collection
Dim enabledList As Collection
Dim unknownList As Collection
Dim notpresentList As Collection
Dim problemList As Collection
Dim cArrayLength As Integer
Dim I As Integer
Dim J As Integer
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim EmailCount As Integer
Dim compArray() As String
'\\ load csv declarations
Dim file_name As String
Dim fnum As Integer
Dim whole_file As String
Dim lines As Variant
Dim one_line As Variant
Dim num_rows As Long
Dim num_cols As Long
Dim R As Long
Dim C As Long
Set disabledList = New Collection
Set enabledList = New Collection
Set unknownList = New Collection
Set notpresentList = New Collection
Set problemList = New Collection
'\\\\\
'\\Retrieve info from outlook, add to sorted list Computers
'\\\\\
objOutlook = CreateObject("Outlook.Application")
Inbox = objOutlook.GetNamespace("Mapi").GetDefaultFolder(6)
InboxItems = Inbox.Items
InboxItems.SetColumns ("SentOn")
Dim myItems As Outlook.Items
Dim dict As Object
Dim msg As String
Set dict = CreateObject("Scripting.Dictionary")
myItems.SetColumns ("SentOn")
EmailCount = InboxItems.Count
For Each Mailobject In InboxItems
strDate = GetDate(Mailobject.SentOn)
If Not dict.Exists(strDate) Then
dict(strDate) = 0
End If
dict(strDate) = CLng(dict(strDate)) + 1
Next Mailobject
'\\ need redo to assign number of objects to CompLength
msg = ""
For Each o In dict.Keys
msg = msg & o & ": " & dict(o) & " items" & vbCrLf
Next
Debug.Print msg
For Each Mailobject In InboxItems
ComputerName = Mailobject.Subject
ErrorState = Mailobject.Body
strDate = GetDate(Mailobject.SentOn)
SenderEmail = Mailobject.SenderEmailAddress
If strDate = DateToday And SenderEmail = "itadmin@email.org" Then
'\\ Syntax is (key, value)
Computers.Add ComputerName, ErrorState
End If
'MsgBox(Mailobject.Subject)
'MsgBox(Mailobject.SenderName)
'MsgBox(Mailobject.To)
'MsgBox(Mailobject.Body)
Next Mailobject
本网站已不仅是一个地方难以置信的帮助,我要问的问题,但也是一个适合我的地方,而不必麻烦你找到所有相关信息。 遗憾的是,往往是我有麻烦你所有,但每次都非常善良,乐于助人。 我想向你表示感谢。