![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing End Sub |
#2
|
|||
|
|||
![]() Month(Date) tells you the current month. -- Best regards Michael Bauer - MVP Outlook Use Outlook Categories? This is Your Tool: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Fri, 22 Feb 2008 10:41:03 -0800 schrieb 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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing End Sub |
#3
|
|||
|
|||
![]()
I am just learning VBA, really just a beginner... how/where would I specify
each e-mail to be sent on a particular month(s) of the year using the month(date) procedure? Thanks for all of your help. It is very much appriciated. ~Gabe "Michael Bauer [MVP - Outlook]" wrote: Month(Date) tells you the current month. -- Best regards Michael Bauer - MVP Outlook Use Outlook Categories? This is Your Tool: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Fri, 22 Feb 2008 10:41:03 -0800 schrieb 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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing End Sub |
#4
|
|||
|
|||
![]()
I think what Michael was suggesting was something like a Select Case
statement. When you run the code it would automatically pick up the current month (from the current date) and select the appropriate recipients. Something like this: Sub SendMonthlyMsgs() Dim olApp As Outlook.Application Dim olMsg As Outlook.MailItem Dim strRecip As Outlook.Recipient Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) ' what month is it? Select Case Month(Date) Case 1 ' January strRecip = "John Smith; Mary Jones" Case 2 ' February strRecip = "John Smith; Mary Jones;Mark Summers" Case 3 ' March strRecip = "John Smith; Mary Jones;Mark Summers;Jane Doe" ' ------------------ ' more Case statements here '------------------ End Select With olMsg .To = strRecip .Subject = "Monthly Report" .Display End With End Sub On Mar 10, 1:29*pm, Gabe wrote: I am just learning VBA, really just a beginner... how/where would I specify each e-mail to be sent on a particular month(s) of the year using the month(date) procedure? Thanks for all of your help. It is very much appriciated. ~Gabe "Michael Bauer [MVP - Outlook]" wrote: Month(Date) tells you the current month. -- Best regards Michael Bauer - MVP Outlook * Use Outlook Categories? This is Your Tool: * http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Fri, 22 Feb 2008 10:41:03 -0800 schrieb 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 = " * *.Subject = "Monthly Report" * *.Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg * *.To = " * *.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 = " * *.Subject = "Monthly Report" * *.Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg * *.To = " * *.Subject = "Monthly Report" * *.Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg * *.To = " * *.Subject = "Monthly Report" * *.Display End With Set olMsg = Nothing Set olApp = Nothing End Sub- Hide quoted text - - Show quoted text - |
#5
|
|||
|
|||
![]()
Hmmm...Actually there are 10 seperate messages all with different recipients
that I send each month. Each procedure varies by month, for example: I send 5 messages in Jan, then I send 7 messages in Feb etc...Is there a way to specify the message itself so that I can see which months each message is being sent? Kinda like this, If month(date) = 1,3,4,5,6,7,8,9,10,11,12 Then 'If the current date matches any of these months, then send this message With olMsg .To = " .Subject = "Monthly Report" .Display End With If month(date) = 1,5,6,7,8,9,10,11,12 Then 'If the current date matches any of these months, then send this message With olMsg .To = " .Subject = "Monthly Report" .Display End With "JP" wrote: I think what Michael was suggesting was something like a Select Case statement. When you run the code it would automatically pick up the current month (from the current date) and select the appropriate recipients. Something like this: Sub SendMonthlyMsgs() Dim olApp As Outlook.Application Dim olMsg As Outlook.MailItem Dim strRecip As Outlook.Recipient Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) ' what month is it? Select Case Month(Date) Case 1 ' January strRecip = "John Smith; Mary Jones" Case 2 ' February strRecip = "John Smith; Mary Jones;Mark Summers" Case 3 ' March strRecip = "John Smith; Mary Jones;Mark Summers;Jane Doe" ' ------------------ ' more Case statements here '------------------ End Select With olMsg .To = strRecip .Subject = "Monthly Report" .Display End With End Sub On Mar 10, 1:29 pm, Gabe wrote: I am just learning VBA, really just a beginner... how/where would I specify each e-mail to be sent on a particular month(s) of the year using the month(date) procedure? Thanks for all of your help. It is very much appriciated. ~Gabe "Michael Bauer [MVP - Outlook]" wrote: Month(Date) tells you the current month. -- Best regards Michael Bauer - MVP Outlook Use Outlook Categories? This is Your Tool: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Fri, 22 Feb 2008 10:41:03 -0800 schrieb 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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .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 = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing Set olApp = Outlook.Application Set olMsg = olApp.CreateItem(olMailItem) With olMsg .To = " .Subject = "Monthly Report" .Display End With Set olMsg = Nothing Set olApp = Nothing End Sub- Hide quoted text - - Show quoted text - |
#6
|
|||
|
|||
![]()
Are you sending the same message each month, just to different
recipients? --JP On Mar 11, 12:53*pm, Gabe wrote: Hmmm...Actually there are 10 seperate messages all with different recipients that I send each month. Each procedure varies by month, for example: I send 5 messages in Jan, then I send 7 messages in Feb etc...Is there a way to specify the message itself so that I can see which months each message is being sent? Kinda like this, If month(date) = 1,3,4,5,6,7,8,9,10,11,12 Then 'If the current date matches any of these months, then send this message With olMsg * * .To = " * * .Subject = "Monthly Report" * * .Display End With If month(date) = 1,5,6,7,8,9,10,11,12 Then 'If the current date matches any of these months, then send this message With olMsg * * .To = " * * .Subject = "Monthly Report" * * .Display End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calendar - Monthly | alleycat | Outlook - General Queries | 1 | September 25th 07 09:54 PM |
monthly calendar | alleycat | Outlook - General Queries | 0 | September 24th 07 11:22 PM |
monthly calendar | alleycat | Outlook - General Queries | 0 | September 24th 07 11:00 PM |
monthly calendar | alleycat | Outlook - General Queries | 1 | September 24th 07 04:50 AM |
Can's able to recieve mails but sending mails | About Outlook Configuration | Outlook - General Queries | 4 | July 5th 06 07:00 PM |