View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
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