Я не уверен, что мне не нравится в моем коде здесь, у меня есть опыт работы в .NET, но VBA для меня новичок. Я знаю, когда вызываемые функции не выполняют myFunction («args») и вместо аргументов myFunction, но у меня нет этой проблемы. Любая помощь приветствуется. Благодаря!Требуемый объект VBA Outlook
Public Sub LogMeIn()
Dim item As Outlook.MailItem
Dim body As String
Dim subject As String
Dim oFld As Outlook.Folder
Dim oNS As Outlook.NameSpace
Dim oMails As Outlook.items
Dim oProp As Outlook.PropertyPage
Dim mySelection As Word.Selection
Dim strItem As String
Dim omailitem As Variant
Set oNS = Application.GetNamespace("MAPI")
Set oFld = oNS.GetDefaultFolder(olFolderInbox)
Set oMails = oFld.items
For Each omailitem In oMails
Set body = omailitem.body
Set subject = omailitem.subject
Dim pos As Integer
Set pos = 0
Dim copyText As String
If InStr(omailitem.subject, "Your LogMeIn Security Code:") > 0 Then
Set copystr = Mid(omailitem.body, pos + 28, 9)
Dim dataToSave As New DataObject
dataToSave.SetText copystr
dataToSave.putinclipboard
'MsgBox ("subject true")
End If
'MsgBox ("subject true")
'If omailitem.subject.Find("Your LogMeIn Security Code:") Then
'MsgBox ("subject true")
'End If
Next
End Sub
Private Sub Application_NewMail()
Call LogMeIn
End Sub
Если мой ответ верен для вас, подумайте принять его для других людей, у которых может быть эта проблема;) –