Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
I am trying to get a send email button to send emails to multiple addresses.
I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Hi LKP
See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Sweet! Thanks Ron!
"Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Oops
Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Thanks, Ron. Do you know how I can make a mcaro button conditional? I want
this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
You can use code like this in the macro to test a cell value
Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Great, Ron. I think that will work. The variable I am looking for is if a
cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Try this
With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Ron-
You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
You are welcome
-- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Sorry. I have another question. Is there a way to make the email screen
appear when someone hits the macro button so they can write a message instead of just automatically sending the email? "Ron de Bruin" wrote: You are welcome -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Do you use Outlook or Outlook Express or Windows Mail ?
-- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sorry. I have another question. Is there a way to make the email screen appear when someone hits the macro button so they can write a message instead of just automatically sending the email? "Ron de Bruin" wrote: You are welcome -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
We use Outlook.
"Ron de Bruin" wrote: Do you use Outlook or Outlook Express or Windows Mail ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sorry. I have another question. Is there a way to make the email screen appear when someone hits the macro button so they can write a message instead of just automatically sending the email? "Ron de Bruin" wrote: You are welcome -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Then use The Outlook object model examples on my site
http://www.rondebruin.nl/sendmail.htm You can use .Display instead of .Send in the code then -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... We use Outlook. "Ron de Bruin" wrote: Do you use Outlook or Outlook Express or Windows Mail ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sorry. I have another question. Is there a way to make the email screen appear when someone hits the macro button so they can write a message instead of just automatically sending the email? "Ron de Bruin" wrote: You are welcome -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#15
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Hi Ron-
The code I have is not working. Here is what I did: Any suggestions? Thanks! Private Sub CommandButton1_Click() 'Working in 2000-2007 Dim wb1 As Workbook Dim wb2 As Workbook Dim TempFilePath As String Dim TempFileName As String Dim FileExtStr As String Dim OutApp As Object Dim OutMail As Object Set wb1 = ActiveWorkbook If Val(Application.Version) = 12 Then If wb1.FileFormat = 51 And wb1.HasVBProject = True Then MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _ "Save the file first as xlsm and then try the macro again.", vbInformation Exit Sub End If End If With Application .ScreenUpdating = False .EnableEvents = False End With 'Make a copy of the file/Open it/Mail it/Delete it 'If you want to change the file name then change only TempFileName TempFilePath = Environ$("temp") & "\" TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1))) wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) On Error Resume Next If LCase(Range("C110").Value) = "exceeds a threshold" Then .DisplayMail ", "), _ "CareTracker Pricing" Else .DisplayMail "), _ "CareTracker Pricing" End With On Error GoTo 0 wb2.Close SaveChanges:=False 'Delete the file Kill TempFilePath & TempFileName & FileExtStr Set OutMail = Nothing Set OutApp = Nothing With Application .ScreenUpdating = True .EnableEvents = True End With End Sub "Ron de Bruin" wrote: Then use The Outlook object model examples on my site http://www.rondebruin.nl/sendmail.htm You can use .Display instead of .Send in the code then -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... We use Outlook. "Ron de Bruin" wrote: Do you use Outlook or Outlook Express or Windows Mail ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sorry. I have another question. Is there a way to make the email screen appear when someone hits the macro button so they can write a message instead of just automatically sending the email? "Ron de Bruin" wrote: You are welcome -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#16
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Use it like this
Sub test() 'Working in 2000-2007 Dim wb1 As Workbook Dim wb2 As Workbook Dim TempFilePath As String Dim TempFileName As String Dim FileExtStr As String Dim OutApp As Object Dim OutMail As Object Set wb1 = ActiveWorkbook If Val(Application.Version) = 12 Then If wb1.FileFormat = 51 And wb1.HasVBProject = True Then MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _ "Save the file first as xlsm and then try the macro again.", vbInformation Exit Sub End If End If With Application .ScreenUpdating = False .EnableEvents = False End With 'Make a copy of the file/Open it/Mail it/Delete it 'If you want to change the file name then change only TempFileName TempFilePath = Environ$("temp") & "\" TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1))) wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail If LCase(Range("C110").Value) = "exceeds a threshold" Then .To = @ingenix. com" Else .To = " End If .CC = "" .BCC = "" .Subject = "CareTracker Pricing" .Body = "Hi there" .Attachments.Add wb2.FullName .Display End With On Error GoTo 0 wb2.Close SaveChanges:=False 'Delete the file Kill TempFilePath & TempFileName & FileExtStr Set OutMail = Nothing Set OutApp = Nothing With Application .ScreenUpdating = True .EnableEvents = True End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Hi Ron- The code I have is not working. Here is what I did: Any suggestions? Thanks! Private Sub CommandButton1_Click() 'Working in 2000-2007 Dim wb1 As Workbook Dim wb2 As Workbook Dim TempFilePath As String Dim TempFileName As String Dim FileExtStr As String Dim OutApp As Object Dim OutMail As Object Set wb1 = ActiveWorkbook If Val(Application.Version) = 12 Then If wb1.FileFormat = 51 And wb1.HasVBProject = True Then MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _ "Save the file first as xlsm and then try the macro again.", vbInformation Exit Sub End If End If With Application .ScreenUpdating = False .EnableEvents = False End With 'Make a copy of the file/Open it/Mail it/Delete it 'If you want to change the file name then change only TempFileName TempFilePath = Environ$("temp") & "\" TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1))) wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) On Error Resume Next If LCase(Range("C110").Value) = "exceeds a threshold" Then .DisplayMail ", "), _ "CareTracker Pricing" Else .DisplayMail "), _ "CareTracker Pricing" End With On Error GoTo 0 wb2.Close SaveChanges:=False 'Delete the file Kill TempFilePath & TempFileName & FileExtStr Set OutMail = Nothing Set OutApp = Nothing With Application .ScreenUpdating = True .EnableEvents = True End With End Sub "Ron de Bruin" wrote: Then use The Outlook object model examples on my site http://www.rondebruin.nl/sendmail.htm You can use .Display instead of .Send in the code then -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... We use Outlook. "Ron de Bruin" wrote: Do you use Outlook or Outlook Express or Windows Mail ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sorry. I have another question. Is there a way to make the email screen appear when someone hits the macro button so they can write a message instead of just automatically sending the email? "Ron de Bruin" wrote: You are welcome -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... I am trying to get a send email button to send emails to multiple addresses. I can get it to work for one address, but I don't know how to do multiples. Here's the code: wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) With wb2 On Error Resume Next .SendMail ", _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True Can anyone help? Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? |
#17
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Send Email" macro to multiple addresses
Great! It works perfectly. Thanks again!
"Ron de Bruin" wrote: Use it like this Sub test() 'Working in 2000-2007 Dim wb1 As Workbook Dim wb2 As Workbook Dim TempFilePath As String Dim TempFileName As String Dim FileExtStr As String Dim OutApp As Object Dim OutMail As Object Set wb1 = ActiveWorkbook If Val(Application.Version) = 12 Then If wb1.FileFormat = 51 And wb1.HasVBProject = True Then MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _ "Save the file first as xlsm and then try the macro again.", vbInformation Exit Sub End If End If With Application .ScreenUpdating = False .EnableEvents = False End With 'Make a copy of the file/Open it/Mail it/Delete it 'If you want to change the file name then change only TempFileName TempFilePath = Environ$("temp") & "\" TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1))) wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail If LCase(Range("C110").Value) = "exceeds a threshold" Then .To = @ingenix. com" Else .To = " End If .CC = "" .BCC = "" .Subject = "CareTracker Pricing" .Body = "Hi there" .Attachments.Add wb2.FullName .Display End With On Error GoTo 0 wb2.Close SaveChanges:=False 'Delete the file Kill TempFilePath & TempFileName & FileExtStr Set OutMail = Nothing Set OutApp = Nothing With Application .ScreenUpdating = True .EnableEvents = True End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Hi Ron- The code I have is not working. Here is what I did: Any suggestions? Thanks! Private Sub CommandButton1_Click() 'Working in 2000-2007 Dim wb1 As Workbook Dim wb2 As Workbook Dim TempFilePath As String Dim TempFileName As String Dim FileExtStr As String Dim OutApp As Object Dim OutMail As Object Set wb1 = ActiveWorkbook If Val(Application.Version) = 12 Then If wb1.FileFormat = 51 And wb1.HasVBProject = True Then MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _ "Save the file first as xlsm and then try the macro again.", vbInformation Exit Sub End If End If With Application .ScreenUpdating = False .EnableEvents = False End With 'Make a copy of the file/Open it/Mail it/Delete it 'If you want to change the file name then change only TempFileName TempFilePath = Environ$("temp") & "\" TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1))) wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr) Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) On Error Resume Next If LCase(Range("C110").Value) = "exceeds a threshold" Then .DisplayMail ", "), _ "CareTracker Pricing" Else .DisplayMail "), _ "CareTracker Pricing" End With On Error GoTo 0 wb2.Close SaveChanges:=False 'Delete the file Kill TempFilePath & TempFileName & FileExtStr Set OutMail = Nothing Set OutApp = Nothing With Application .ScreenUpdating = True .EnableEvents = True End With End Sub "Ron de Bruin" wrote: Then use The Outlook object model examples on my site http://www.rondebruin.nl/sendmail.htm You can use .Display instead of .Send in the code then -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... We use Outlook. "Ron de Bruin" wrote: Do you use Outlook or Outlook Express or Windows Mail ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sorry. I have another question. Is there a way to make the email screen appear when someone hits the macro button so they can write a message instead of just automatically sending the email? "Ron de Bruin" wrote: You are welcome -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Ron- You are a genius! Thank you so much. It works perfectly. "Ron de Bruin" wrote: Try this With wb2 On Error Resume Next If LCase(Range("A1").Value) = "exceeds a threshold" Then .SendMail ", "), _ "This is the Subject line" Else .SendMail ", "), _ "This is the Subject line" End If On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Great, Ron. I think that will work. The variable I am looking for is if a cell says "Exceeds a Threshold". How would I put this into the code? Also, if I need to send to multiple addresses, can I use the array feature you showed me earlier? Thanks "Ron de Bruin" wrote: You can use code like this in the macro to test a cell value Dim ToStr As String If LCase(Range("A1").Value) = "yes" Then ToStr = " Else ToStr = " End If With wb2 On Error Resume Next .SendMail ToStr, _ "Product" On Error GoTo 0 .Close SaveChanges:=False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Thanks, Ron. Do you know how I can make a mcaro button conditional? I want this "Send Email" button to one person if certain conditions are met and another person if these conditions are not met. "Ron de Bruin" wrote: Oops Also, when I click on this button, a security warning pops up asking if I want to enable the macros, which I do. How do I turn that pop up off? You can change the security Use the shortcut to go to that dialog Alt tms -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "LKP" wrote in message ... Sweet! Thanks Ron! "Ron de Bruin" wrote: Hi LKP See http://www.rondebruin.nl/mail/tips1.htm -- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to send email to multiple addresses | Excel Worksheet Functions | |||
Excel Macro to email to addresses in "Contacts" Tab | Excel Programming | |||
copy/convert column email addresses Hyperlink "mailto:" excel97 | Excel Discussion (Misc queries) | |||
Email from Excel; MS warning "program is trying to send mail on your behalf" | Excel Programming | |||
VB code to "Send To" Multi addresses | Excel Programming |