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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail attachement from Global Variable

Status
Not open for further replies.

sedgely

Technical User
Feb 21, 2002
406
GB
i have a task that creates and populates a text file, the text file. i then use an activeX taask to copy and rename the file from using a global variable and yesterdays date as the file name.
i now want to email the file as an attachment, but because the file name is different each day, i'm not sure how to achieve this, can anyone suggest a solution.

Thanks

Cheers, Craig
Si fractum non sit, noli id reficere
 
Function Main()
Dim objMessage
Dim myMail

Set myMail=CreateObject("CDO.Message")

myMail.Subject="subject text"
myMail.From="emailaddress@company.com"
myMail.To="recipient1@company.com;recipient2@company.com"
myMail.TextBody="body text"
myMail.AddAttachment "C:\" & DTSGlobalVariables("variable").Value & DateAdd(d,-1,Now()) & ".txt"
myMail.Configuration.Fields.Item _
(" 'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
(" _
="MN02SE01.atk.com"
'Server port
myMail.Configuration.Fields.Item _
(" _
=25
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing

Main = DTSTaskExecResult_Success
End Function
 
oops, forgot to change the smtp server value...chagne the following:
Code:
myMail.Configuration.Fields.Item _
        ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] _
        =[s]"MN02SE01.atk.com"[/s] "YourSMTPServerNameOrIPAddress"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top