cancel
Showing results for 
Search instead for 
Did you mean: 

How to send mail with attachment file ?

chandrasekhar6
Participant
0 Kudos

Hi All,

When I used below script to sent a mail successfully,

smtp_to('abc@gmail.com','Subject','Message',0,5);

Then how to send mail with attachment file.

when i tried below scn link,

Please share needful information.

Thanks,

Chandra. K

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member208402
Active Contributor
0 Kudos

hi Chandra,

Use VBScript method. We implemented in the same way.

chandrasekhar6
Participant
0 Kudos

Hi Ravi,

When my process as below:

Step 1: Configure SMTP Server

Step 2: save .vbs file in E:/ drive in shared folder.

In vbs scripts as below,

strSMTPFrom = "abc@gmail.com"   

strSMTPTo = "cdf@gnail.com"

strSMTPRelay = "smtp server name given"

strTextBody = "JOB_NAME completed successfully in UAT. Attached is the file load status."

strSubject = "JOB_NAME completed in UAT"

strAttachment = "\\E:\Demo\Status_File.csv"

                         Set oMessage = CreateObject("CDO.Message")

                     oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

                     oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay

                     oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

                     oMessage.Configuration.Fields.Update

                     oMessage.Subject = strSubject

                     oMessage.From = strSMTPFrom

                     oMessage.To = strSMTPTo

                     oMessage.TextBody = strTextBody

                     oMessage.AddAttachment strAttachment

                      oMessage.Send

and

Script written as below,

exec('CScript','[$G_PROCESSED_LOCATION]\email.vbs',8);

here [$G_PROCESSED_LOCATION] = '\\E:\Demo\' with data type varchar(255)



When i execute job in Administrator login also not send mail.

Please share needful information.

Thanks,

Chandra. K

former_member208402
Active Contributor
0 Kudos

Hi Chandra,


Please try this and let me know if this works.


exec('CScript','\\[$G_PROCESSED_LOCATION]\\email.vbs',0);

chandrasekhar6
Participant
0 Kudos

Hi Ravi,

Thanks for response

When it try above script it shows error and modifit 0 to 8 and apply it execute but not sent mail

Thanks,

Chandra Sekhar

former_member208402
Active Contributor
0 Kudos

Hi Chandra,

Please try this.

print(exec('cscript','[$G_PROCESSED_LOCATION]\\email.vbs',8));

chandrasekhar6
Participant
0 Kudos

Hi Ravi,

Thanks for quick response.

When I try above script job executed successfully but not send mail,as shown below,

When i tried execute administrator login also not able to send mail.

Thanks,

Chandra. K

former_member208402
Active Contributor
0 Kudos

Hi Chandra,

if you see the log "Network Path was not found".. this issue might me with the some connection/configurations or might be in the script.

Also check if you have given all the required parameters in the below script

strSMTPFrom = <<Server from which mail alert will be sent>>

strSMTPTo = <<To_list to whom mail needs to be sent>> #We can have substitution parameter define with list of E-mail ids to which this to be sent

strSMTPRelay = <<SMTP Relay mail>>  #like the domain from which mails will be sent

strTextBody = <<E-mail BODY>

strSubject = <<E-mail Subject>

StrAttachment = <<Specify the shared drive path from where file to be attached is present>> eg: D:\Kshop\Sample\Rejected

Set oMessage = CreateObject("CDO.Message")

  • oMessage.Subject = strSubject
  • oMessage.From = strSMTPFrom
  • oMessage.To = strSMTPTo
  • oMessage.TextBody = strTextBody
  • oMessage.AddAttachment strAttachment
  • oMessage.Send
chandrasekhar6
Participant
0 Kudos

Hi Ravi,


Thanks for quick response,


When I wrote script as below,


strSMTPFrom ="siva.kumar@gmail.com" #here mail also define at data service servermanager <<Server from which mail alert will be sent>>

strSMTPTo = "chadnrasekhar@gmail.com" ##Target file sending mail

<<To_list to whom mail needs to be sent>>

#We can have substitution parameter define with list of E-mail ids to which this to be sent

strSMTPRelay = "smtp.ourcompany.com" ##define smtp server name<<SMTP Relay mail>>  #like the domain from which mails will be sent

strTextBody = ""Job success"<<E-mail BODY>

strSubject = "Message"<<E-mail Subject>

StrAttachment ="\\E:\Demo\Status_File.csv" #target file path

<<Specify the shared drive path from where file to be attached is present>> eg: D:\Kshop\Sample\Rejected

Set oMessage = CreateObject("CDO.Message")

  • oMessage.Subject = strSubject
  • oMessage.From = strSMTPFrom
  • oMessage.To = strSMTPTo
  • oMessage.TextBody = strTextBody
  • oMessage.AddAttachment strAttachment
  • oMessage.Send

  • script code:

  print(exec('cscript','[$G_PROCESSED_LOCATION]\\email.vbs',8));

   here [$G_PROCESSED_LOCATION] = '\\\E:\Demo' data type varchar(222)

and Job server details as shown below,

Thanks,

Chandra. K

former_member208402
Active Contributor
0 Kudos

Hi Chandra sekhar,

Is your location name is like '\\\E:\Demo'  or you gave extra \\

former_member198401
Active Contributor
0 Kudos

Chandra,

Did you correct the code

oMessage.AddAttachment strAttachment

it should be

oMessage.AddAttachment = strAttachment

I am not good with VB scripting, but logic says that we need to pass strAttachment to the function call Message.AddAttachment

Regards

Arun Sasi

chandrasekhar6
Participant
0 Kudos

Hi Ravi,

Thanks for response

There no mistake in script , outlook not installed in my server so getting issue.

Thanks,

Chandra

vnovozhilov
Employee
Employee
0 Kudos

You may use 3rd-party SMTP client supporting attachments, instead of default one.

You would need to amend DSConfig.txt file accordingly.

Thank you,

Viacheslav.