Emailing workbook from Excel

G

Guest

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
 
G

Guest

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top