![]() |
Emailing workbook from Excel
Hi,
I am trying to use the following macro from Rondebruin's site, but am encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas? Also, is there a simpler way to get the email to open through Outlook, rather than putting in server details (see below)? The purpose of this macro is to open an email from Excel and Word and attach the open document. Thank you for your assistance Georgie Sub CDO_Send_Workbook() 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 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 .Subject = "This is a test" .TextBody = "This is the body text" .AddAttachment "C:/" & WBname End With Set iMsg = Nothing Set iConf = Nothing Set wb = Nothing Application.ScreenUpdating = True End Sub |
Emailing workbook from Excel
Hi Georgie8888
I am trying to use the following macro from Rondebruin's site, but am encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas? Do you hava a C drive ? See my site for a lot of Outlook examples Use Display instead of Send in the code http://www.rondebruin.nl/mail/folder2/mail1.htm Or http://www.rondebruin.nl/mail/folder1/mail1.htm -- Regards Ron de Bruin http://www.rondebruin.nl "Georgie8888" wrote in message ... Hi, I am trying to use the following macro from Rondebruin's site, but am encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas? Also, is there a simpler way to get the email to open through Outlook, rather than putting in server details (see below)? The purpose of this macro is to open an email from Excel and Word and attach the open document. Thank you for your assistance Georgie Sub CDO_Send_Workbook() 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 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 .Subject = "This is a test" .TextBody = "This is the body text" .AddAttachment "C:/" & WBname End With Set iMsg = Nothing Set iConf = Nothing Set wb = Nothing Application.ScreenUpdating = True End Sub |
Emailing workbook from Excel
Hi Ron,
Thanks for your help. I used the code from your first link and it works a treat. Now just need to figure out how to do the same thing in Word. Regards, Georgie "Ron de Bruin" wrote: Hi Georgie8888 I am trying to use the following macro from Rondebruin's site, but am encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas? Do you hava a C drive ? See my site for a lot of Outlook examples Use Display instead of Send in the code http://www.rondebruin.nl/mail/folder2/mail1.htm Or http://www.rondebruin.nl/mail/folder1/mail1.htm -- Regards Ron de Bruin http://www.rondebruin.nl "Georgie8888" wrote in message ... Hi, I am trying to use the following macro from Rondebruin's site, but am encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas? Also, is there a simpler way to get the email to open through Outlook, rather than putting in server details (see below)? The purpose of this macro is to open an email from Excel and Word and attach the open document. Thank you for your assistance Georgie Sub CDO_Send_Workbook() 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 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 .Subject = "This is a test" .TextBody = "This is the body text" .AddAttachment "C:/" & WBname End With Set iMsg = Nothing Set iConf = Nothing Set wb = Nothing Application.ScreenUpdating = True End Sub |
Emailing workbook from Excel
Dear Ron,
I am running your CDo option and ca send internal mail but it is not allowing to send external mail. I have confirmed that our SMTP gateway is operational and the port is the correct one. Any ideas. -- Thank you in advance for your Help "Ron de Bruin" wrote: Hi Georgie8888 I am trying to use the following macro from Rondebruin's site, but am encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas? Do you hava a C drive ? See my site for a lot of Outlook examples Use Display instead of Send in the code http://www.rondebruin.nl/mail/folder2/mail1.htm Or http://www.rondebruin.nl/mail/folder1/mail1.htm -- Regards Ron de Bruin http://www.rondebruin.nl "Georgie8888" wrote in message ... Hi, I am trying to use the following macro from Rondebruin's site, but am encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas? Also, is there a simpler way to get the email to open through Outlook, rather than putting in server details (see below)? The purpose of this macro is to open an email from Excel and Word and attach the open document. Thank you for your assistance Georgie Sub CDO_Send_Workbook() 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 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 .Subject = "This is a test" .TextBody = "This is the body text" .AddAttachment "C:/" & WBname End With Set iMsg = Nothing Set iConf = Nothing Set wb = Nothing Application.ScreenUpdating = True End Sub |
All times are GMT +1. The time now is 02:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com