This is an extract of a script that works very well. I would just like to improve it somewhat.
The script loops through a spreadsheet, creates folders, creates new files, and sends them by email according to certain conditions.
In current state of things, an email address is always found, either vendor or buyer. If no address were to be found I would get an error message ("Email not sent, no address found to mail to"
and that would kill my loop.
Lotus notes must have a RECIPIENT
I would like to be able to keep looping if:
Column J is not blank (which means "DO NOT SEND EMAIL"
How would I change bolded portion here below.
Do
EmailVendorNo = EmailList.Sheets("list"
.Range("A" + CStr(j)).Value
If (EmailVendorNo = CurrentVendorNo) Then
RECIPIENT= EmailList.Sheets("list"
.Range("f" + CStr(j)).Value
Subject = "Aged Report"
End If
If (EmailList.Sheets("list"
.Range("j" + CStr(j))) <> "" Then
With Workbooks("VendorEmailAddresses.xls"
.Worksheets("Buyers"
BuyerRecipient = WorksheetFunction.VLookup(Cells(5, 1).Value, .Range(.Cells(1, 1), .Cells(19, 2)), 2, False)
End With
RECIPIENT= BuyerRecipient
Subject = "Report not sent to vendor as per buyer's request"
End If
....... there are 2 more if conditions after this point
j = j + 1
Loop Until EmailVendorNo = currentVendorNo Or EmailVendorNo = ""
'Start Lotus Notes application
Const EMBED_ATTACHMENT = 1454
Set session = CreateObject("Notes.NotesSession"
Set db = session.GetDatabase("", ""
Call db.OpenMail
Set doc = db.CreateDocument
msg = "Please find herewith..." & vbCrLf & _
Call doc.ReplaceItemValue("SendTo", RECIPIENT
)
Call doc.ReplaceItemValue("Subject", Subject)
Basically what I want:
If there is an instruction on spreadsheet (DO NOT SEND AUTOMATICALLY) simply skip that vendor and keep looping through others.
Any suggestions anyone ???
Thanks.
The script loops through a spreadsheet, creates folders, creates new files, and sends them by email according to certain conditions.
In current state of things, an email address is always found, either vendor or buyer. If no address were to be found I would get an error message ("Email not sent, no address found to mail to"
Lotus notes must have a RECIPIENT
I would like to be able to keep looping if:
Column J is not blank (which means "DO NOT SEND EMAIL"
How would I change bolded portion here below.
Do
EmailVendorNo = EmailList.Sheets("list"
If (EmailVendorNo = CurrentVendorNo) Then
RECIPIENT= EmailList.Sheets("list"
Subject = "Aged Report"
End If
If (EmailList.Sheets("list"
With Workbooks("VendorEmailAddresses.xls"
BuyerRecipient = WorksheetFunction.VLookup(Cells(5, 1).Value, .Range(.Cells(1, 1), .Cells(19, 2)), 2, False)
End With
RECIPIENT= BuyerRecipient
Subject = "Report not sent to vendor as per buyer's request"
End If
....... there are 2 more if conditions after this point
j = j + 1
Loop Until EmailVendorNo = currentVendorNo Or EmailVendorNo = ""
'Start Lotus Notes application
Const EMBED_ATTACHMENT = 1454
Set session = CreateObject("Notes.NotesSession"
Set db = session.GetDatabase("", ""
Call db.OpenMail
Set doc = db.CreateDocument
msg = "Please find herewith..." & vbCrLf & _
Call doc.ReplaceItemValue("SendTo", RECIPIENT
)
Call doc.ReplaceItemValue("Subject", Subject)
Basically what I want:
If there is an instruction on spreadsheet (DO NOT SEND AUTOMATICALLY) simply skip that vendor and keep looping through others.
Any suggestions anyone ???
Thanks.