Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dear all, I have taken some code I found on Ron DeBruins website, but when I run it it flashes up "object required". Any suggestions as to why this happens ? FYI I am running the macro from a network location. The to, from and subject lines are based on the values in A1, A2 and A3. Thanks in advance Amy xx Sub CDO_Mail_Every_Worksheet_File() Dim iMsg As Object Dim iConf As Object Dim ws As Worksheet Dim wb As Workbook Dim WBname As String ' Dim Flds As Variant Application.ScreenUpdating = False For Each ws In ThisWorkbook.Worksheets If ws.Range("a1").Value Like "?*@?*.?*" Then ws.Copy Set wb = ActiveWorkbook '' ChDir "S:\Files\temporary folder" WBname = "S:\Files\temporary folder\ " & ws.Name & ".xls" wb.SaveAs WBname wb.Close False Set wb = Nothing Set iMsg = CreateObject("CDO.Message", "S:\scott\temporary folder\" & ws.Name & ".xls") With iMsg Set .Configuration = iConf ..To = ws.Range("a1").Value ..From = s.Range("a2").Value ..Subject = "Sheet: " & ws.Name ..AddAttachment WBname ..TextBody = ws.Range("a3").Value ..Fields("urn:schemas:mailheader:X-Priority") = 1 ..Send End With Set iMsg = Nothing Kill WBname End If Next ws Set iConf = Nothing Application.ScreenUpdating = True End Sub -- AmyTaylor ------------------------------------------------------------------------ AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970 View this thread: http://www.excelforum.com/showthread...hreadid=519648 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this is what I use....
Private Sub SendMailCDOCacheConf(aTo, Subject, TextBody, aFrom) Const cdoSendUsingPort = 2 Dim Conf Set Conf = CreateObject("CDO.Configuration") With Conf.Fields .item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort .item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "bhmail1.rivagecapital.com" .Update End With Dim Message 'As New CDO.Message 'Create CDO message object Set Message = CreateObject("CDO.Message") With Message 'Set cached configuration Set .Configuration = Conf 'Set email adress, subject And body .To = aTo .Subject = Subject .TextBody = TextBody 'Set sender address If specified. If Len(aFrom) 0 Then .From = aFrom 'Send the message .send End With End Sub "AmyTaylor" wrote: Dear all, I have taken some code I found on Ron DeBruins website, but when I run it it flashes up "object required". Any suggestions as to why this happens ? FYI I am running the macro from a network location. The to, from and subject lines are based on the values in A1, A2 and A3. Thanks in advance Amy xx Sub CDO_Mail_Every_Worksheet_File() Dim iMsg As Object Dim iConf As Object Dim ws As Worksheet Dim wb As Workbook Dim WBname As String ' Dim Flds As Variant Application.ScreenUpdating = False For Each ws In ThisWorkbook.Worksheets If ws.Range("a1").Value Like "?*@?*.?*" Then ws.Copy Set wb = ActiveWorkbook '' ChDir "S:\Files\temporary folder" WBname = "S:\Files\temporary folder\ " & ws.Name & ".xls" wb.SaveAs WBname wb.Close False Set wb = Nothing Set iMsg = CreateObject("CDO.Message", "S:\scott\temporary folder\" & ws.Name & ".xls") With iMsg Set .Configuration = iConf .To = ws.Range("a1").Value .From = s.Range("a2").Value .Subject = "Sheet: " & ws.Name .AddAttachment WBname .TextBody = ws.Range("a3").Value .Fields("urn:schemas:mailheader:X-Priority") = 1 .Send End With Set iMsg = Nothing Kill WBname End If Next ws Set iConf = Nothing Application.ScreenUpdating = True End Sub -- AmyTaylor ------------------------------------------------------------------------ AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970 View this thread: http://www.excelforum.com/showthread...hreadid=519648 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I use macro in Excel 2007 to convert to and email PDF file | Excel Worksheet Functions | |||
Problem with macro to email xls | Excel Discussion (Misc queries) | |||
Email from macro problem | Excel Programming | |||
Save a file and send as an email - written into macro | Excel Programming | |||
Add shortcut instead of file to Email with Macro | Excel Programming |