LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default URGENT! Please please help me get smtp mail send working..

Hi all,

I am trying desperately to do SMTP mail send and have never done it
before, im getting an automation error on the .send line and I dont
know anything about this

the code below: nothing matters except sending a sheet through email,
the only thing i need to know is how to make it work.

This code I think I got it from Ron or Chip I cant remember now, please
help make it work?

Private Sub CommandButton1_Click()

Dim iMsg As Object
Dim iConf As Object
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim WBname As String
' Dim Flds As Variant

Application.ScreenUpdating = False
Set WB1 = ActiveWorkbook

Sheets("Sheet3").Copy
'Other possibility's are
'ActiveSheet.Copy
'Sheets(Array("Sheet1", "Sheet3")).Copy

Set WB2 = ActiveWorkbook

' It will save the new file with the ActiveSheet in C:/ with a Date
and Time stamp
WBname = "Part of " & WB1.Name & " " & Format(Now, "dd-mm-yy
h-mm-ss") & ".xls"
WB2.SaveAs "C:/" & WBname
WB2.Close False

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") =
"100.1.120.2"

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
.Update
End With

With iMsg
Set .Configuration = iConf
.To = "
.CC = ""
.BCC = ""
.From = """Me"" "
.Subject = "This is a test"
.TextBody = "Hi there"
'.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 WB1 = Nothing
Set WB2 = Nothing
Application.ScreenUpdating = True
End Sub


Many thanks in advance

Duncan

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bypass: A program is trying to send mail using Item.Send prompt Vick Excel Discussion (Misc queries) 1 June 25th 09 03:31 AM
Send an e-mail Pa Maher Excel Discussion (Misc queries) 1 September 16th 07 04:27 PM
"Send to Mail Recipient" icon not working Lynde Excel Discussion (Misc queries) 7 June 23rd 05 04:17 PM
Sending mail from Excel with CDO - return SMTP value Kent Excel Programming 1 February 22nd 05 04:03 PM
How can I send data from excel thru smtp bender Excel Programming 1 November 7th 03 12:48 PM


All times are GMT +1. The time now is 06:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"