![]() |
Sending e-mail using CDO
I used Ron de Bruin's code from his site http://www.rondebruin.nl/cdo.htm
However, when I run it I get this error The "SendUsing" configuration value is invalid. Am I missing a reference maybe? Below is the code. Sub submitclick() Dim iMsg As Object Dim iConf As Object Dim wb As Workbook Dim WBname As String ' Dim Flds As Variant Application.ScreenUpdating = False Set wb = ActiveWorkbook ' It will save a copy of the file in C:/ with a Date and Time stamp WBname = wb.Name & " " & Format(Now, "dd-mm-yy h-mm-ss") & ".xls" wb.SaveCopyAs "C:/" & WBname Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") ' iConf.Load -1 ' CDO Source Defaults ' Set Flds = iConf.Fields ' With Flds ' ..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' ..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in your SMTP server here" ' ..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ' .Update ' End With With iMsg Set .Configuration = iConf .To = " ' .CC = "" ' .BCC = "" ' .From = """"" " .Subject = "Out of Office Request" ' .TextBody = "This is the body text" .AddAttachment "C:/" & WBname .Send End With 'If you not want to delete the file you send delete this line Kill "C:/" & WBname Set iMsg = Nothing Set iConf = Nothing Set wb = Nothing Application.ScreenUpdating = True End Sub |
Sending e-mail using CDO
Hi Kevin
If you not use Outlook Express you must use the commented lines in the code and fill in your SMTP server Read the information on the website -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Kevin Porter" wrote in message ... I used Ron de Bruin's code from his site http://www.rondebruin.nl/cdo.htm However, when I run it I get this error The "SendUsing" configuration value is invalid. Am I missing a reference maybe? Below is the code. Sub submitclick() Dim iMsg As Object Dim iConf As Object Dim wb As Workbook Dim WBname As String ' Dim Flds As Variant Application.ScreenUpdating = False Set wb = ActiveWorkbook ' It will save a copy of the file in C:/ with a Date and Time stamp WBname = wb.Name & " " & Format(Now, "dd-mm-yy h-mm-ss") & ".xls" wb.SaveCopyAs "C:/" & WBname Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") ' iConf.Load -1 ' CDO Source Defaults ' Set Flds = iConf.Fields ' With Flds ' .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in your SMTP server here" ' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ' .Update ' End With With iMsg Set .Configuration = iConf .To = " ' .CC = "" ' .BCC = "" ' .From = """"" " .Subject = "Out of Office Request" ' .TextBody = "This is the body text" .AddAttachment "C:/" & WBname .Send End With 'If you not want to delete the file you send delete this line Kill "C:/" & WBname Set iMsg = Nothing Set iConf = Nothing Set wb = Nothing Application.ScreenUpdating = True End Sub |
All times are GMT +1. The time now is 08:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com