Home > Software engineering >  Vba, Excel automatically reply code error request a great god
Vba, Excel automatically reply code error request a great god

Time:12-19

Code written in excel2013 automatic reply due to the 2016 upgrade win10 excel version update, when executed to automation error request the great spirit guide (please ignore code in the code for Japanese character)
Sub Outlookmail () Application. ScreenUpdating=False Dim nameList As Range
Dim lastRow As Long
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim outlookApp As Object Set sht1=ThisWorkbook. Worksheets (" Namelist ")
The Set sht2=ThisWorkbook. Worksheets (" mail 撪 梕 ")
A1048576 lastRow=sht1. Range (" "). The End (xlUp). A Row For Each nameList In sht1. Range (a2: "a" & amp; LastRow) If nameList & lt;> "" Then Set outlookApp=CreateObject("outlook.application") Dim olNs As Outlook.Namespace Dim flDr As Outlook.MAPIFolder Dim mailReply As Outlook.MailItem Dim iTm As Outlook.MailItem Dim foldername As String foldername=ThisWorkbook.Worksheets("mail撪梕").Range("B2").Value Set outlookApp=New Outlook.Application Set olNs=outlookApp.GetNamespace("MAPI") Set flDr=olNs.GetDefaultFolder(olFolderInbox).Folders(foldername) 'Set myTasks=flDr.Items For Each iTm In flDr.Items If nameList.Value=https://bbs.csdn.net/topics/iTm.To And iTm.Subject="亂FMO亃愝旛専廂埶棅 Request for asset acceptance." Then Set mailReply=iTm.ReplyAll mailReply.Subject="儕儅僀儞僪: 亂FMO亃愝旛専廂埶棅 Request for asset acceptance." mailReply.Body=sht2.Range("a2").Value + mailReply.Body mailReply.Display nameList.Offset(0, 1)="仜" Exit For Else nameList.Offset(0, 1)="亊" On Error Resume Next End If Next Else MsgBox "namelist傪擖椡偟偰偔偩偝偄" End If Next Set outlookApp=Nothing
The Set outlookApp=Nothing
The Set olNs=Nothing
The Set of flDr=Nothing
'Set the myTasks=Nothing Application. ScreenUpdating=True End Sub

CodePudding user response:

Have a great spirit consult!

CodePudding user response:

Sub Outlookmail ()


Application. ScreenUpdating=False

Dim nameList As Range
Dim lastRow As Long
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim outlookApp As Object




The Set sht1=ThisWorkbook. Worksheets (" Namelist ")
The Set sht2=ThisWorkbook. Worksheets (" mail 撪 梕 ")
A1048576 lastRow=sht1. Range (" "). The End (xlUp). Row

For Each nameList In sht1. Range (a2: "a" & amp; LastRow)

If nameList & lt;> "" Then

The Set outlookApp=CreateObject (" outlook. Application ")
Dim olNs As Outlook. The Namespace
Dim flDr As Outlook. MAPIFolder
Dim mailReply As Outlook. MailItem
Dim iTm As Outlook. MailItem
Dim foldername As String


Foldername=ThisWorkbook. Worksheets (" mail 撪 梕 "). The Range (" B2 "). The Value

The Set outlookApp=New Outlook. Application
The Set olNs=outlookApp. GetNamespace (MAPI)
Set flDr=olNs. GetDefaultFolder (olFolderInbox) Folders (foldername)
'Set the myTasks=flDr. Items

For Each iTm In flDr. Items


If nameList. Value=https://bbs.csdn.net/topics/iTm.To And iTm. Subject="disorderly FMO 亃 愝 Fan 専 compartments 埶 bing Request for asset acceptance." Then

The Set mailReply=iTm. ReplyAll

Many when 僀 mailReply. Subject="儞 僪 : disorderly FMO 亃 愝 Fan 専 compartments 埶 bing Request for asset acceptance."
MailReply. Body=sht2. Range (" a2 "). The Value + mailReply. Body
MailReply. Display

NameList. Offset (0, 1)="仜
"The Exit For

The Else

NameList. Offset (0, 1)="dwyane
"On the Error Resume Next



End the If

Next

The Else

MsgBox "namelist 傪 擖 椡 Huang 偰 偔 偩 Bei 偄"

End the If


Next

The Set outlookApp=Nothing
The Set outlookApp=Nothing
The Set olNs=Nothing
The Set of flDr=Nothing
'Set the myTasks=Nothing

Application. ScreenUpdating=True

End Sub

CodePudding user response:

Already solved! Thank you [face] monkey2:005 PNG [/face] [face] monkey2:005 PNG [/face]
  •  Tags:  
  • VBA