I have code that works well to open an email from a folder, extract the excel sheet from the email and save it to the same folder, close the message. What I want to do is to reply to that email with some specific wording. I have the below code but it is not working. I know its the "From" email address but i can't figure out where my error is. I am sure that it is something simple but i just don't know enough to fix it. I have looked at many topics here but just can't seem to crack the code. Please help me
Set Outapp = GetObject(, "Outlook.Application")
Set outEmail = Outapp.Session.OpenSharedItem(PORFQFolder & Filename)
For Each outAttachment In outEmail.Attachments
If outAttachment.Filename Like "*.xls*" Then
POUploadFile1 = PORFQFolder & outAttachment.Filename
outAttachment.SaveAsFile PORFQFolder & outAttachment.Filename
QuoteFile = "Y"
End If
Next
With outEmail
.ReplyAll
.to = .SenderEmailAddress
.HTMLbody = "Your quote has been received and processed."
.display
.send
End With
CodePudding user response:
The .ReplyAll
line actually create a new email whereas you are continuing to work with the received email ... replace your With
block with this:
With outEmail.ReplyAll
.To = outEmail.SenderEmailAddress
.HTMLBody = "Your quote has been received and processed."
.Display
.Send
End With