Oprichnick
Board Regular
- Joined
- May 30, 2013
- Messages
- 69
Hello,
I have this piece of code that is not delivering the result I intend, but I can't figure out what is wrong.
Using OR Statement, in the first line of the piece of code below, I thought that it would send one email even if both YYY and ZZZ were present. Instead it sends two emails if both conditions exist.
I would like to send email if one or another condition is true, but not send two if both are true.
ws is worksheets.
I have this piece of code that is not delivering the result I intend, but I can't figure out what is wrong.
Using OR Statement, in the first line of the piece of code below, I thought that it would send one email even if both YYY and ZZZ were present. Instead it sends two emails if both conditions exist.
I would like to send email if one or another condition is true, but not send two if both are true.
ws is worksheets.
Code:
If ((ws.Name = "YYY") Or (ws.Name = "ZZZ")) Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.SentOnBehalfOfName = "man@blabla.com"
.to = "man2@blabla.com"
.cc = ""
.bcc = ""
.Subject = "Reports"
.body = "blablabla"
.Attachments.Add "C:\foldeaddress\BBB.xlsx"
.display
Last edited: