Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO attaches multiple attachments

Status
Not open for further replies.
Jul 19, 2003
132
NZ
I have a problem with a script that uses CDO to email reports as attachments to various email addresses.

Basically the script iterates through a text file to determine what reports to run, what format to export it to, and who to emailk the exported report to.

I won't bore you with the entire script, but let me know if you need it, just the emailing bits:

It starts with:

'Prepare Email Objects
Set objMyMail = CreateObject("CDO.Message")
Set objConfig = CreateObject("CDO.Configuration")

At the end of the loop it has:

'Set Email options
objMyMail.From = "pshragent_prod"
objMyMail.To = Send_To
objMyMail.Subject = Report_Name
objMyMail.htmlbody = Send_Text

' Email the output
Set Fields = objConfig.Fields
Fields.Item(" = 2
Fields.Item(" = "172.22.1.208"
Fields.Item(" = 25
Fields.Item(" = "text/html"
Fields.Update

Set objMyMail.Configuration = objConfig
objMyMail.addattachment (Pub_Report & Output_Format)

'.MIMEFormatted = False
objMyMail.Send
Print #1, Spc(5), "'" & Pub_Report & "' sent by email"

impRep.CloseReport
set impRep=Nothing
Set objMyMail = Nothing
Set objConfig = Nothing
Set Fields = Nothing

If it's like this then I only the first email in the text file is sent.

If I comment out:

Set objMyMail = Nothing
Set objConfig = Nothing

I get all 3 emails defined in the text file, but the second email gets the attachement intended for the first and second, the third email gets the attachments intended for the first seconfd and third, so 3 attachments, all should only have one each.

Even though the variables within the script show as containing the right data at the right time.

I've tried setting various variables to nothing, but it doesn't help.

I think I need some way to re-initialise CDO so attachment data from the first loop isn't carried over to the second and so on.

I hope I've explained it clearly, sorry I'm not a programmer.

Any ideas?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top