![]() |
| 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. |
|
|||||||
| Tags: disable, guard, model, object, possible |
|
|
|
Thread Tools | Display Modes |
|
#11
|
|||
|
|||
|
Remove this line. It serves no purpose:
Set objMessage = CreateObject("CDO.Message") As for the error message. Do you have the SMTP service running on your machine? If not you'll have to use a remote server probably with authentciation. See http://www.paulsadowski.com/WSH/cdo.htm for examples on how to do that. As far as I know the only way to stop the security warnings is to self-host your own security certificate. But then I'm not an Outlook or Office guy so I could be wrong. "ryguy7272" wrote in message ... Welcome to the party Paul. I believe there is a way to send multiple emails, via Outlook, without those warnings popping up every 5 second, but I have never actually done it. I tried your method, and eliminated all of the Outlook references, and as far as I can tell now, I rely only on CDO to do the job, but now I get an error message saying 'The 'Sendusing' configuration is invalid.'. Code breaks he myMail.Send Entire macro he Sub Send_Files() Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range Set myMail = CreateObject("CDO.Message") myMail.Subject = "Sending email with CDO" With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With OutMail myMail.To = cell.Value myMail.Subject = "Sales Reps. Data" myMail.TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then myMail.AddAttachment FileCell.Value End If End If Next FileCell myMail.Send End With Set OutMail = Nothing End If Next cell Set myMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub If anyone can tweak the code and get this thing to work I'd appreciate it. My CDO ideas came from he http://www.w3schools.com/asp/asp_send_email.asp Regards, Ryan--- -- RyGuy "Paul R. Sadowski" wrote: Get rid of all that Outlook stuff. You are using CDO. CDO is independant of Outlook. Use ONLY CDO. Your warnings are popping up because you are trying to get Outlook to send mail. Use only CDO. No Outlook. "ryguy7272" wrote in message ... Good site Sue, unfortunately I still get an error... Error says: 'The SendUsing configuration value is invalid' This is the line that causes the error: objMessage.Send The Object Model Guard pops up again if I change the line to this: .Send Below is my full code: Sub Send_Files() 'Working in 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set objMessage = CreateObject("CDO.Message") 'Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) 'Enter the file names in the C:Z column in each row Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then Set OutMail = OutApp.CreateItem(0) With OutMail objMessage.Subject = "Example CDO Message" objMessage.From = " objMessage.To = cell.Value objMessage.TextBody = "This is some sample message text." .To = cell.Value .Subject = "Sales Reps. Data" .Body = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell objMessage.Send End With Set OutMail = Nothing End If Next cell Set OutApp = Nothing Set objCDOMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub I am receptive to ideas... Thanks to all who looked. Ryan-- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: I don't do CDO for Windows programming. The page at http://www.paulsadowski.com/WSH/cdo.htm is an excellent reference and shows how you need to provide configuration information about the SMTP server to be used for sending the message. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... I did some editing; still get errors. Error occurs he Set .Configuration = cdoConfig Entire macro: Sub Send_Files() Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set myMail = CreateObject("CDO.Message") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With cdoMessage Set .Configuration = cdoConfig '.From = "" .To = cell.Value .Subject = "Sample CDO Message" .TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell .Send End With Set objMessage = Nothing Set myMail = Nothing End If Next cell With Application .EnableEvents = True .ScreenUpdating = True End With End Sub I've hit a wall again. I've seen your name all over the Outlook-Programming DGs. and I'll bet anything you know what to do from here Sue. I want to learn this, so please tell me what to do to resolve the problem, or please refer me to a resource on the web that explains what to do. Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: Which statement is raising the error? Why are you coding both the Outlook.MailItem, which you know will raise security prompts, and the CDO.Message, which won't? "ryguy7272" wrote in message news
Thanks for the follow up Sue. I guess I still don't understand what makes this work or not work. Not, I am using this code: With OutMail objMessage.To = cell.Value objMessage.Subject = "Sales Reps. Data" objMessage.Body = "Sales Reps. Data" .To = cell.Value .Subject = "Sales Reps. Data" .Body = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell objMessage.Send End With When code runs I get this: Object doesn't support this property or method. What am I doing wrong. If there is something specific that I need to know, please tell me. I don't know much about Outlook at all. Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: If you read that page, you'd know that the object model guard can't be disabled except by an Exchange administrator. Your code creates a CDO.Message object but never sends it. That's an approach you can take, instead of using Outlook objects and getting prompts. "ryguy7272" wrote in message ... I read the information he http://www.outlookcode.com/article.aspx?id=52 It is very interesting. Maybe I missed something, but I still can't seem to disable the Outlook Object Model Guard. I am sending multiple emails from Excel. code is below: Sub Send_Files() 'Working in 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With |
| Ads |
|
#12
|
|||
|
|||
|
Ryan, Paul knows what he's talking about and has documented what you need to know in the article I suggested to you earlier at http://www.paulsadowski.com/WSH/cdo.htm. The problem with your code is that you're still not setting the Message.Configuration details that make it possible for CDO to know what SMTP server address to send through.
You also ought to take out the With OutMail and End With statements, as they're confusing and add nothing to the code. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... Welcome to the party Paul. I believe there is a way to send multiple emails, via Outlook, without those warnings popping up every 5 second, but I have never actually done it. I tried your method, and eliminated all of the Outlook references, and as far as I can tell now, I rely only on CDO to do the job, but now I get an error message saying 'The 'Sendusing' configuration is invalid.'. Code breaks he myMail.Send Entire macro he Sub Send_Files() Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range Set myMail = CreateObject("CDO.Message") myMail.Subject = "Sending email with CDO" With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With OutMail myMail.To = cell.Value myMail.Subject = "Sales Reps. Data" myMail.TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then myMail.AddAttachment FileCell.Value End If End If Next FileCell myMail.Send End With Set OutMail = Nothing End If Next cell Set myMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub If anyone can tweak the code and get this thing to work I'd appreciate it. My CDO ideas came from he http://www.w3schools.com/asp/asp_send_email.asp Regards, Ryan--- -- RyGuy "Paul R. Sadowski" wrote: Get rid of all that Outlook stuff. You are using CDO. CDO is independant of Outlook. Use ONLY CDO. Your warnings are popping up because you are trying to get Outlook to send mail. Use only CDO. No Outlook. "ryguy7272" wrote in message ... Good site Sue, unfortunately I still get an error... Error says: 'The SendUsing configuration value is invalid' This is the line that causes the error: objMessage.Send The Object Model Guard pops up again if I change the line to this: .Send Below is my full code: Sub Send_Files() 'Working in 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set objMessage = CreateObject("CDO.Message") 'Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) 'Enter the file names in the C:Z column in each row Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then Set OutMail = OutApp.CreateItem(0) With OutMail objMessage.Subject = "Example CDO Message" objMessage.From = " objMessage.To = cell.Value objMessage.TextBody = "This is some sample message text." .To = cell.Value .Subject = "Sales Reps. Data" .Body = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell objMessage.Send End With Set OutMail = Nothing End If Next cell Set OutApp = Nothing Set objCDOMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub I am receptive to ideas... Thanks to all who looked. Ryan-- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: I don't do CDO for Windows programming. The page at http://www.paulsadowski.com/WSH/cdo.htm is an excellent reference and shows how you need to provide configuration information about the SMTP server to be used for sending the message. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... I did some editing; still get errors. Error occurs he Set .Configuration = cdoConfig Entire macro: Sub Send_Files() Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set myMail = CreateObject("CDO.Message") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With cdoMessage Set .Configuration = cdoConfig '.From = "" .To = cell.Value .Subject = "Sample CDO Message" .TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell .Send End With Set objMessage = Nothing Set myMail = Nothing End If Next cell With Application .EnableEvents = True .ScreenUpdating = True End With End Sub I've hit a wall again. I've seen your name all over the Outlook-Programming DGs. and I'll bet anything you know what to do from here Sue. I want to learn this, so please tell me what to do to resolve the problem, or please refer me to a resource on the web that explains what to do. Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: Which statement is raising the error? Why are you coding both the Outlook.MailItem, which you know will raise security prompts, and the CDO.Message, which won't? "ryguy7272" wrote in message news
Thanks for the follow up Sue. I guess I still don't understand what makes this work or not work. Not, I am using this code: With OutMail objMessage.To = cell.Value objMessage.Subject = "Sales Reps. Data" objMessage.Body = "Sales Reps. Data" .To = cell.Value .Subject = "Sales Reps. Data" .Body = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell objMessage.Send End With When code runs I get this: Object doesn't support this property or method. What am I doing wrong. If there is something specific that I need to know, please tell me. I don't know much about Outlook at all. Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: If you read that page, you'd know that the object model guard can't be disabled except by an Exchange administrator. Your code creates a CDO.Message object but never sends it. That's an approach you can take, instead of using Outlook objects and getting prompts. "ryguy7272" wrote in message ... I read the information he http://www.outlookcode.com/article.aspx?id=52 It is very interesting. Maybe I missed something, but I still can't seem to disable the Outlook Object Model Guard. I am sending multiple emails from Excel. code is below: Sub Send_Files() 'Working in 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With |
|
#13
|
|||
|
|||
|
I’ve tried all sorts of things, but I still don't know how to set the
Message.Configuration details for CDO. Also, I don’t know if I am running SMPT or not. I know almost nothing about programming Outlook. I just wanted to help a few people in my office with some tasks around here. I've got it working for the most part, but I just wanted to try to eliminate those popups. I am sort of busy with other projects now, so I'll have to come back to this sometime in the future. Thanks so much, Sue and Paul, for the valiant effort. I wish I could have gotten it to work, but it doesn't seem like it is going to happen anytime soon. I’ll take another crack at it another time. Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: Ryan, Paul knows what he's talking about and has documented what you need to know in the article I suggested to you earlier at http://www.paulsadowski.com/WSH/cdo.htm. The problem with your code is that you're still not setting the Message.Configuration details that make it possible for CDO to know what SMTP server address to send through. You also ought to take out the With OutMail and End With statements, as they're confusing and add nothing to the code. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... Welcome to the party Paul. I believe there is a way to send multiple emails, via Outlook, without those warnings popping up every 5 second, but I have never actually done it. I tried your method, and eliminated all of the Outlook references, and as far as I can tell now, I rely only on CDO to do the job, but now I get an error message saying 'The 'Sendusing' configuration is invalid.'. Code breaks he myMail.Send Entire macro he Sub Send_Files() Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range Set myMail = CreateObject("CDO.Message") myMail.Subject = "Sending email with CDO" With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With OutMail myMail.To = cell.Value myMail.Subject = "Sales Reps. Data" myMail.TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then myMail.AddAttachment FileCell.Value End If End If Next FileCell myMail.Send End With Set OutMail = Nothing End If Next cell Set myMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub If anyone can tweak the code and get this thing to work I'd appreciate it. My CDO ideas came from he http://www.w3schools.com/asp/asp_send_email.asp Regards, Ryan--- -- RyGuy "Paul R. Sadowski" wrote: Get rid of all that Outlook stuff. You are using CDO. CDO is independant of Outlook. Use ONLY CDO. Your warnings are popping up because you are trying to get Outlook to send mail. Use only CDO. No Outlook. "ryguy7272" wrote in message ... Good site Sue, unfortunately I still get an error... Error says: 'The SendUsing configuration value is invalid' This is the line that causes the error: objMessage.Send The Object Model Guard pops up again if I change the line to this: .Send Below is my full code: Sub Send_Files() 'Working in 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set objMessage = CreateObject("CDO.Message") 'Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) 'Enter the file names in the C:Z column in each row Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then Set OutMail = OutApp.CreateItem(0) With OutMail objMessage.Subject = "Example CDO Message" objMessage.From = " objMessage.To = cell.Value objMessage.TextBody = "This is some sample message text." .To = cell.Value .Subject = "Sales Reps. Data" .Body = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell objMessage.Send End With Set OutMail = Nothing End If Next cell Set OutApp = Nothing Set objCDOMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub I am receptive to ideas... Thanks to all who looked. Ryan-- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: I don't do CDO for Windows programming. The page at http://www.paulsadowski.com/WSH/cdo.htm is an excellent reference and shows how you need to provide configuration information about the SMTP server to be used for sending the message. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... I did some editing; still get errors. Error occurs he Set .Configuration = cdoConfig Entire macro: Sub Send_Files() Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set myMail = CreateObject("CDO.Message") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With cdoMessage Set .Configuration = cdoConfig '.From = "" .To = cell.Value .Subject = "Sample CDO Message" .TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell .Send End With Set objMessage = Nothing Set myMail = Nothing End If Next cell With Application .EnableEvents = True .ScreenUpdating = True End With End Sub |
|
#14
|
|||
|
|||
|
Ok, I couldn't just leave it alone; I like to finish whatever I start.
I found this code: Dim myOlApp As Outlook.Application Dim mpfInbox As Outlook.MAPIFolder Dim obj As Outlook.MailItem Dim myOlExp As Outlook.Explorer Dim myOlSel As Outlook.Selection Set myOlApp = CreateObject("Outlook.Application") Set mpfInbox = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox) If mpfInbox.Items(1).Class = olMail Then Set obj = mpfInbox.Items.Item(1) MsgBox obj.SenderEmailAddress End If This causes a prompt that asks if a user would like to 'Allow Access for x Minutes'. I thought, ok, good, I’d like to allow access for 1 minute, that's all it will take to send my emails. I thought the Outlook security prompts would be disabled for 1 minute, but no, another popup comes up and I have to 'Allow' all the email to be sent just like before, by clicking the 'Yes' button each time. The code does give me my SMTP server address, right. I think that’s what it is called. obj.SenderEmailAddress Also, to get Excel to cooperate with Outlook, I had to add this line back in: Set objMessage = CreateObject("CDO.Message") Well, I guess I made a little progress, but it still doesn’t do what I envisioned it doing. Any more suggestions, recommendations, etc.? Sorry for being so thick with all this stuff. Ryan--- -- RyGuy "ryguy7272" wrote: I’ve tried all sorts of things, but I still don't know how to set the Message.Configuration details for CDO. Also, I don’t know if I am running SMPT or not. I know almost nothing about programming Outlook. I just wanted to help a few people in my office with some tasks around here. I've got it working for the most part, but I just wanted to try to eliminate those popups. I am sort of busy with other projects now, so I'll have to come back to this sometime in the future. Thanks so much, Sue and Paul, for the valiant effort. I wish I could have gotten it to work, but it doesn't seem like it is going to happen anytime soon. I’ll take another crack at it another time. Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: Ryan, Paul knows what he's talking about and has documented what you need to know in the article I suggested to you earlier at http://www.paulsadowski.com/WSH/cdo.htm. The problem with your code is that you're still not setting the Message.Configuration details that make it possible for CDO to know what SMTP server address to send through. You also ought to take out the With OutMail and End With statements, as they're confusing and add nothing to the code. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... Welcome to the party Paul. I believe there is a way to send multiple emails, via Outlook, without those warnings popping up every 5 second, but I have never actually done it. I tried your method, and eliminated all of the Outlook references, and as far as I can tell now, I rely only on CDO to do the job, but now I get an error message saying 'The 'Sendusing' configuration is invalid.'. Code breaks he myMail.Send Entire macro he Sub Send_Files() Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range Set myMail = CreateObject("CDO.Message") myMail.Subject = "Sending email with CDO" With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With OutMail myMail.To = cell.Value myMail.Subject = "Sales Reps. Data" myMail.TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then myMail.AddAttachment FileCell.Value End If End If Next FileCell myMail.Send End With Set OutMail = Nothing End If Next cell Set myMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub If anyone can tweak the code and get this thing to work I'd appreciate it. My CDO ideas came from he http://www.w3schools.com/asp/asp_send_email.asp Regards, Ryan--- -- RyGuy "Paul R. Sadowski" wrote: Get rid of all that Outlook stuff. You are using CDO. CDO is independant of Outlook. Use ONLY CDO. Your warnings are popping up because you are trying to get Outlook to send mail. Use only CDO. No Outlook. "ryguy7272" wrote in message ... Good site Sue, unfortunately I still get an error... Error says: 'The SendUsing configuration value is invalid' This is the line that causes the error: objMessage.Send The Object Model Guard pops up again if I change the line to this: .Send Below is my full code: Sub Send_Files() 'Working in 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set objMessage = CreateObject("CDO.Message") 'Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) 'Enter the file names in the C:Z column in each row Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then Set OutMail = OutApp.CreateItem(0) With OutMail objMessage.Subject = "Example CDO Message" objMessage.From = " objMessage.To = cell.Value objMessage.TextBody = "This is some sample message text." .To = cell.Value .Subject = "Sales Reps. Data" .Body = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell objMessage.Send End With Set OutMail = Nothing End If Next cell Set OutApp = Nothing Set objCDOMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub I am receptive to ideas... Thanks to all who looked. Ryan-- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: I don't do CDO for Windows programming. The page at http://www.paulsadowski.com/WSH/cdo.htm is an excellent reference and shows how you need to provide configuration information about the SMTP server to be used for sending the message. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... I did some editing; still get errors. Error occurs he Set .Configuration = cdoConfig Entire macro: Sub Send_Files() Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set myMail = CreateObject("CDO.Message") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With cdoMessage Set .Configuration = cdoConfig '.From = "" .To = cell.Value .Subject = "Sample CDO Message" .TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then |
|
#15
|
|||
|
|||
|
Look in your mail account settings. If you're using POP3 or IMAP4 for mail accounts, you will also see outbound SMTP settings. If you are using Exchange, you will need to discuss things with your Exchange administrator.
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... I’ve tried all sorts of things, but I still don't know how to set the Message.Configuration details for CDO. Also, I don’t know if I am running SMPT or not. I know almost nothing about programming Outlook. I just wanted to help a few people in my office with some tasks around here. I've got it working for the most part, but I just wanted to try to eliminate those popups. I am sort of busy with other projects now, so I'll have to come back to this sometime in the future. Thanks so much, Sue and Paul, for the valiant effort. I wish I could have gotten it to work, but it doesn't seem like it is going to happen anytime soon. I’ll take another crack at it another time. Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: Ryan, Paul knows what he's talking about and has documented what you need to know in the article I suggested to you earlier at http://www.paulsadowski.com/WSH/cdo.htm. The problem with your code is that you're still not setting the Message.Configuration details that make it possible for CDO to know what SMTP server address to send through. You also ought to take out the With OutMail and End With statements, as they're confusing and add nothing to the code. "ryguy7272" wrote in message ... Welcome to the party Paul. I believe there is a way to send multiple emails, via Outlook, without those warnings popping up every 5 second, but I have never actually done it. I tried your method, and eliminated all of the Outlook references, and as far as I can tell now, I rely only on CDO to do the job, but now I get an error message saying 'The 'Sendusing' configuration is invalid.'. Code breaks he myMail.Send Entire macro he Sub Send_Files() Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range Set myMail = CreateObject("CDO.Message") myMail.Subject = "Sending email with CDO" With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With OutMail myMail.To = cell.Value myMail.Subject = "Sales Reps. Data" myMail.TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then myMail.AddAttachment FileCell.Value End If End If Next FileCell myMail.Send End With Set OutMail = Nothing End If Next cell Set myMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub If anyone can tweak the code and get this thing to work I'd appreciate it. My CDO ideas came from he http://www.w3schools.com/asp/asp_send_email.asp Regards, Ryan--- -- RyGuy "Paul R. Sadowski" wrote: Get rid of all that Outlook stuff. You are using CDO. CDO is independant of Outlook. Use ONLY CDO. Your warnings are popping up because you are trying to get Outlook to send mail. Use only CDO. No Outlook. "ryguy7272" wrote in message ... Good site Sue, unfortunately I still get an error... Error says: 'The SendUsing configuration value is invalid' This is the line that causes the error: objMessage.Send The Object Model Guard pops up again if I change the line to this: .Send Below is my full code: Sub Send_Files() 'Working in 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set objMessage = CreateObject("CDO.Message") 'Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) 'Enter the file names in the C:Z column in each row Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then Set OutMail = OutApp.CreateItem(0) With OutMail objMessage.Subject = "Example CDO Message" objMessage.From = " objMessage.To = cell.Value objMessage.TextBody = "This is some sample message text." .To = cell.Value .Subject = "Sales Reps. Data" .Body = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell objMessage.Send End With Set OutMail = Nothing End If Next cell Set OutApp = Nothing Set objCDOMail = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub I am receptive to ideas... Thanks to all who looked. Ryan-- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: I don't do CDO for Windows programming. The page at http://www.paulsadowski.com/WSH/cdo.htm is an excellent reference and shows how you need to provide configuration information about the SMTP server to be used for sending the message. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... I did some editing; still get errors. Error occurs he Set .Configuration = cdoConfig Entire macro: Sub Send_Files() Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range, FileCell As Range, rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Send Emails") Set myMail = CreateObject("CDO.Message") Set objMessage = CreateObject("CDO.Message") For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConst ants) Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1") If cell.Value Like "?*@?*.?*" And _ Application.WorksheetFunction.CountA(rng) 0 Then With cdoMessage Set .Configuration = cdoConfig '.From = "" .To = cell.Value .Subject = "Sample CDO Message" .TextBody = "Hi " & cell.Offset(0, -1).Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) "" Then If Dir(FileCell.Value) "" Then .Attachments.Add FileCell.Value End If End If Next FileCell .Send End With Set objMessage = Nothing Set myMail = Nothing End If Next cell With Application .EnableEvents = True .ScreenUpdating = True End With End Sub |
|
#16
|
|||
|
|||
|
As described in the article you were referred to at http://www.outlookcode.com/article.aspx?ID=52, there are two types of prompts -- a time-limited prompt for access to address-limited information and a prompt for sending messages that appears for each message.
The sender's email address has nothing to do with the SMTP server that you would use to deliver an outgoing message. See my response to your other post. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... Ok, I couldn't just leave it alone; I like to finish whatever I start. I found this code: Dim myOlApp As Outlook.Application Dim mpfInbox As Outlook.MAPIFolder Dim obj As Outlook.MailItem Dim myOlExp As Outlook.Explorer Dim myOlSel As Outlook.Selection Set myOlApp = CreateObject("Outlook.Application") Set mpfInbox = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox) If mpfInbox.Items(1).Class = olMail Then Set obj = mpfInbox.Items.Item(1) MsgBox obj.SenderEmailAddress End If This causes a prompt that asks if a user would like to 'Allow Access for x Minutes'. I thought, ok, good, I’d like to allow access for 1 minute, that's all it will take to send my emails. I thought the Outlook security prompts would be disabled for 1 minute, but no, another popup comes up and I have to 'Allow' all the email to be sent just like before, by clicking the 'Yes' button each time. The code does give me my SMTP server address, right. I think that’s what it is called. obj.SenderEmailAddress Also, to get Excel to cooperate with Outlook, I had to add this line back in: Set objMessage = CreateObject("CDO.Message") Well, I guess I made a little progress, but it still doesn’t do what I envisioned it doing. Any more suggestions, recommendations, etc.? Sorry for being so thick with all this stuff. |
|
#17
|
|||
|
|||
|
After querying some great resources, both in my office and on the web, I've
come to the conclusion that this can't be done practically with our Outlook mail system. The IT guys would have to give certain types of permission, which they won't do, even if they did have time to do it. I could use other technologies, but I really wanted to send the emails through Outlook, so I could find certain files in my 'Sent Items' if I needed to. This is certainly not possible with some of the other technology options at my firm, because those other email tools literally bypass Outlook altogether. Anyway, this was a great resource: http://www.rondebruin.nl/cdo.htm I learned a lot by reading the information here. I hope others can too... Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: As described in the article you were referred to at http://www.outlookcode.com/article.aspx?ID=52, there are two types of prompts -- a time-limited prompt for access to address-limited information and a prompt for sending messages that appears for each message. The sender's email address has nothing to do with the SMTP server that you would use to deliver an outgoing message. See my response to your other post. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... Ok, I couldn't just leave it alone; I like to finish whatever I start. I found this code: Dim myOlApp As Outlook.Application Dim mpfInbox As Outlook.MAPIFolder Dim obj As Outlook.MailItem Dim myOlExp As Outlook.Explorer Dim myOlSel As Outlook.Selection Set myOlApp = CreateObject("Outlook.Application") Set mpfInbox = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox) If mpfInbox.Items(1).Class = olMail Then Set obj = mpfInbox.Items.Item(1) MsgBox obj.SenderEmailAddress End If This causes a prompt that asks if a user would like to 'Allow Access for x Minutes'. I thought, ok, good, I’d like to allow access for 1 minute, that's all it will take to send my emails. I thought the Outlook security prompts would be disabled for 1 minute, but no, another popup comes up and I have to 'Allow' all the email to be sent just like before, by clicking the 'Yes' button each time. The code does give me my SMTP server address, right. I think that’s what it is called. obj.SenderEmailAddress Also, to get Excel to cooperate with Outlook, I had to add this line back in: Set objMessage = CreateObject("CDO.Message") Well, I guess I made a little progress, but it still doesn’t do what I envisioned it doing. Any more suggestions, recommendations, etc.? Sorry for being so thick with all this stuff. |
|
#18
|
|||
|
|||
|
I also like Paul's article on CDO for Windows at http://www.paulsadowski.com/WSH/cdo.htm a lot and recommend it to people looking to use CDO to send messages without security prompts.
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "ryguy7272" wrote in message ... After querying some great resources, both in my office and on the web, I've come to the conclusion that this can't be done practically with our Outlook mail system. The IT guys would have to give certain types of permission, which they won't do, even if they did have time to do it. I could use other technologies, but I really wanted to send the emails through Outlook, so I could find certain files in my 'Sent Items' if I needed to. This is certainly not possible with some of the other technology options at my firm, because those other email tools literally bypass Outlook altogether. Anyway, this was a great resource: http://www.rondebruin.nl/cdo.htm I learned a lot by reading the information here. I hope others can too... Regards, Ryan--- -- RyGuy "Sue Mosher [MVP-Outlook]" wrote: As described in the article you were referred to at http://www.outlookcode.com/article.aspx?ID=52, there are two types of prompts -- a time-limited prompt for access to address-limited information and a prompt for sending messages that appears for each message. The sender's email address has nothing to do with the SMTP server that you would use to deliver an outgoing message. See my response to your other post. "ryguy7272" wrote in message ... Ok, I couldn't just leave it alone; I like to finish whatever I start. I found this code: Dim myOlApp As Outlook.Application Dim mpfInbox As Outlook.MAPIFolder Dim obj As Outlook.MailItem Dim myOlExp As Outlook.Explorer Dim myOlSel As Outlook.Selection Set myOlApp = CreateObject("Outlook.Application") Set mpfInbox = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox) If mpfInbox.Items(1).Class = olMail Then Set obj = mpfInbox.Items.Item(1) MsgBox obj.SenderEmailAddress End If This causes a prompt that asks if a user would like to 'Allow Access for x Minutes'. I thought, ok, good, I’d like to allow access for 1 minute, that's all it will take to send my emails. I thought the Outlook security prompts would be disabled for 1 minute, but no, another popup comes up and I have to 'Allow' all the email to be sent just like before, by clicking the 'Yes' button each time. The code does give me my SMTP server address, right. I think that’s what it is called. obj.SenderEmailAddress Also, to get Excel to cooperate with Outlook, I had to add this line back in: Set objMessage = CreateObject("CDO.Message") Well, I guess I made a little progress, but it still doesn’t do what I envisioned it doing. Any more suggestions, recommendations, etc.? Sorry for being so thick with all this stuff. |