G
Gabe
I have some code that automatically sends e-mails each month to different
poeple. Each month the e-mails are different (for example: In January I send
2 e-mails and in Febuary I send 3 e-mails). So now I have been forced to make
a separate code under a different module for each month of the year. The
problem is that when I have to add a new e-mail contact to the list, I have
to spend hours changing each code(one for each month of the year). Is there a
way to make only one code but then specify who to include in each month? So
that I can just change 1 code and not 12? Here is an example of what it looks
like:
Sub January()'Module 1
Dim olApp As Outlook.Application
Dim olMsg As Outlook.MailItem
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
End Sub
Sub Febuary()'Module 2
Dim olApp As Outlook.Application
Dim olMsg As Outlook.MailItem
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
End Sub
poeple. Each month the e-mails are different (for example: In January I send
2 e-mails and in Febuary I send 3 e-mails). So now I have been forced to make
a separate code under a different module for each month of the year. The
problem is that when I have to add a new e-mail contact to the list, I have
to spend hours changing each code(one for each month of the year). Is there a
way to make only one code but then specify who to include in each month? So
that I can just change 1 code and not 12? Here is an example of what it looks
like:
Sub January()'Module 1
Dim olApp As Outlook.Application
Dim olMsg As Outlook.MailItem
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
End Sub
Sub Febuary()'Module 2
Dim olApp As Outlook.Application
Dim olMsg As Outlook.MailItem
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = "Monthly Report"
.Display
End With
Set olMsg = Nothing
Set olApp = Nothing
End Sub