Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Sending mail from excel with CDO

Can anyone tell me where I am going wrong here. I get
errors on the .To line and the .AddAttachment line
(doesn't like the variables I guess) I also get an error
on the Kill line.


For i = 1 To k
'get the address of the intended receipient
name = Cells(rnum + i, 3).Value
& "
Debug.Print name
' get the name of the file to attach
aname = Cells(2, 4).Value & Cells(rnum + i,
8) & ".rft"
Debug.Print aname

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .configuration = iConf
.To = "name"
.From = "
.Subject = "WEEKLY FLASH REPORT"
.Textbody = Cells(rnum + 1, 6).Value & vbNewLine
& "Please forward your comments/changes to Dan Sorenson
or Gary Bilyk."
.AddAttachment = "aname"
.Send
End With

Kill "aname"


Next i


Thanks
Christy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Sending mail from excel with CDO

Should the file extension be "rtf"?
Make sure you are not confusing variable names with
variable contents, e.g
aname is the variable
Its content is: Cells(2, 4).Value & Cells(rnum + i,
8) & ".rft"

"aname" is a string whose value is: "aname"
Similarly, should be
.To = name
not
.To = "name"

You could also add code such as
If Dir(aname) < "" Then
Kill aname
End If

to confirm file existence before you delete

Kevin Beckham
-----Original Message-----
Can anyone tell me where I am going wrong here. I get
errors on the .To line and the .AddAttachment line
(doesn't like the variables I guess) I also get an error
on the Kill line.


For i = 1 To k
'get the address of the intended receipient
name = Cells(rnum + i, 3).Value
& "
Debug.Print name
' get the name of the file to attach
aname = Cells(2, 4).Value & Cells(rnum + i,
8) & ".rft"
Debug.Print aname

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .configuration = iConf
.To = "name"
.From = "
.Subject = "WEEKLY FLASH REPORT"
.Textbody = Cells(rnum + 1, 6).Value & vbNewLine
& "Please forward your comments/changes to Dan Sorenson
or Gary Bilyk."
.AddAttachment = "aname"
.Send
End With

Kill "aname"


Next i


Thanks
Christy

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Sending mail from excel with CDO

Thanks Kevin,

Yes, it was supposed to be rtf not rft
Taking the quotes from around name seems to be working
and kill suggestion worked also.

Now my only problem is the .AddAttachment
I can't get this to work with or without the quotes. Any
suggestions?

You help is greatly appreciated.
Christy


-----Original Message-----
Should the file extension be "rtf"?
Make sure you are not confusing variable names with
variable contents, e.g
aname is the variable
Its content is: Cells(2, 4).Value & Cells(rnum + i,
8) & ".rft"

"aname" is a string whose value is: "aname"
Similarly, should be
.To = name
not
.To = "name"

You could also add code such as
If Dir(aname) < "" Then
Kill aname
End If

to confirm file existence before you delete

Kevin Beckham
-----Original Message-----
Can anyone tell me where I am going wrong here. I get
errors on the .To line and the .AddAttachment line
(doesn't like the variables I guess) I also get an

error
on the Kill line.


For i = 1 To k
'get the address of the intended receipient
name = Cells(rnum + i, 3).Value
& "
Debug.Print name
' get the name of the file to attach
aname = Cells(2, 4).Value & Cells(rnum + i,
8) & ".rft"
Debug.Print aname

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .configuration = iConf
.To = "name"
.From = "
.Subject = "WEEKLY FLASH REPORT"
.Textbody = Cells(rnum + 1, 6).Value &

vbNewLine
& "Please forward your comments/changes to Dan Sorenson
or Gary Bilyk."
.AddAttachment = "aname"
.Send
End With

Kill "aname"


Next i


Thanks
Christy

.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Sending mail from excel with CDO

Christy

Try
.AddAttachment aname

as .AddAttachment is a function, not a property

Kevin Beckham

-----Original Message-----
Thanks Kevin,

Yes, it was supposed to be rtf not rft
Taking the quotes from around name seems to be working
and kill suggestion worked also.

Now my only problem is the .AddAttachment
I can't get this to work with or without the quotes. Any
suggestions?

You help is greatly appreciated.
Christy


-----Original Message-----
Should the file extension be "rtf"?
Make sure you are not confusing variable names with
variable contents, e.g
aname is the variable
Its content is: Cells(2, 4).Value & Cells(rnum + i,
8) & ".rft"

"aname" is a string whose value is: "aname"
Similarly, should be
.To = name
not
.To = "name"

You could also add code such as
If Dir(aname) < "" Then
Kill aname
End If

to confirm file existence before you delete

Kevin Beckham
-----Original Message-----
Can anyone tell me where I am going wrong here. I get
errors on the .To line and the .AddAttachment line
(doesn't like the variables I guess) I also get an

error
on the Kill line.


For i = 1 To k
'get the address of the intended receipient
name = Cells(rnum + i, 3).Value
& "
Debug.Print name
' get the name of the file to attach
aname = Cells(2, 4).Value & Cells(rnum + i,
8) & ".rft"
Debug.Print aname

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .configuration = iConf
.To = "name"
.From = "
.Subject = "WEEKLY FLASH REPORT"
.Textbody = Cells(rnum + 1, 6).Value &

vbNewLine
& "Please forward your comments/changes to Dan Sorenson
or Gary Bilyk."
.AddAttachment = "aname"
.Send
End With

Kill "aname"


Next i


Thanks
Christy

.

.

.

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 multipul e-mail from excel Carl R[_2_] Excel Discussion (Misc queries) 1 September 22nd 09 10:18 AM
Excel file sending an e-mail, is possible? Mukesh Excel Discussion (Misc queries) 14 August 20th 08 07:16 AM
sending an excel attachment in an e-mail drumane Excel Discussion (Misc queries) 2 April 21st 08 04:14 PM
Sending One Cell Through Mail from Excel Man Mohan Singh Excel Worksheet Functions 1 April 27th 07 10:56 AM
General mail failure when sending e-mail from Excel Adrienne Excel Discussion (Misc queries) 5 November 4th 05 12:59 PM


All times are GMT +1. The time now is 10:05 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"