0

I'm trying to get mailitem by Outlook.application object, and reply email by certain subject naming rule. Now I'm able to get the mailitem, filter the mail by its subject. How can I move the next step to reply email? Thanks

Belo is my code so far:

Set objOutlook = CreateObject("Outlook.Application")
Set MailItem = objOutlook.Session.Folders("XXX@XXX.com")
For Each eMail in MailItem.Items
    If InStr(1,Trim(eMail.Subject),"Production",vbTextCompare) > 0 then
    wscript.echo "This is needed email, need to reply"
    End If
Next

1 Answers1

0

For wscript use, you can modify the example found in Outlook Reply or ReplyAll to an Email

You pull eMail in your loop of Mail items

Use this in place of wscript.echo line

Set olReply = eMail.ReplyAll
olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
olReply.Display
olReply.Send
dbmitch
  • 5,361
  • 4
  • 24
  • 38