Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add attachment to CDO email

Having trouble aading an attachment to CDO email

Sub Send_Margins()
Dim cdoConfig
Dim msgOne

Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"mail.mailserver.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
.Update
'.Item(cdoSendUserName) = "UserName"
'.Item(cdoSendPassword) = "Password"
End With

Set msgOne = CreateObject("CDO.Message")
Set msgOne.Configuration = cdoConfig
msgOne.To = "
msgOne.CC = "
msgOne.From = "
msgOne.Subject = "hello"
msgOne.TextBody = "test test test"
msgOne.Attachments.Add "C:\Documents and Settings\j.doe\Desktop\MarginImp.
xls"
msgOne.Send
End Sub

I get "Type mismatch" error on this line
msgOne.Attachments.Add "C:\Documents and Settings\j.doe\Desktop\MarginImp.
xls"

also tried
Dim MI As Object
Set MI = Workbooks("C:\Documents and Settings\j.doe\Desktop\MarginImp.xls")

msgOne.Attachments = MI

but get "Subscript out of range" on the Set MI line

any ideas?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200708/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Add attachment to CDO email

See
http://www.rondebruin.nl/cdo.htm

It is
..AddAttachment


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"blackbox" <u20390@uwe wrote in message news:771bab4e81e20@uwe...
Having trouble aading an attachment to CDO email

Sub Send_Margins()
Dim cdoConfig
Dim msgOne

Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"mail.mailserver.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
.Update
'.Item(cdoSendUserName) = "UserName"
'.Item(cdoSendPassword) = "Password"
End With

Set msgOne = CreateObject("CDO.Message")
Set msgOne.Configuration = cdoConfig
msgOne.To = "
msgOne.CC = "
msgOne.From = "
msgOne.Subject = "hello"
msgOne.TextBody = "test test test"
msgOne.Attachments.Add "C:\Documents and Settings\j.doe\Desktop\MarginImp.
xls"
msgOne.Send
End Sub

I get "Type mismatch" error on this line
msgOne.Attachments.Add "C:\Documents and Settings\j.doe\Desktop\MarginImp.
xls"

also tried
Dim MI As Object
Set MI = Workbooks("C:\Documents and Settings\j.doe\Desktop\MarginImp.xls")

msgOne.Attachments = MI

but get "Subscript out of range" on the Set MI line

any ideas?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200708/1

Reply
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
Sending a Spreadsheet as an Email Attachment vs. Imbedded in Email billbrandi Excel Discussion (Misc queries) 1 April 3rd 08 03:44 AM
send wkbk as an email attachment with an email address copied from SueInAtl Excel Discussion (Misc queries) 0 May 21st 07 10:53 PM
email attachment Holden Caulfield New Users to Excel 0 April 19th 07 05:02 PM
email as attachment swimbugs Excel Discussion (Misc queries) 1 March 28th 07 02:14 AM
VBA to Email Attachment Jim Palmer[_2_] Excel Programming 3 July 10th 04 04:44 PM


All times are GMT +1. The time now is 10:28 AM.

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

About Us

"It's about Microsoft Excel"