Forums.MrPLC.com: Send Emails with Attachments - Forums.MrPLC.com

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Send Emails with Attachments Rate Topic: -----

#1
User is offline   lostcontrol 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 370
  • Joined: 27-May 09
  • Country:New Zealand
    New Zealand
I am using the VB script below, but want to use the AddAttachment option.

Trouble is, when I un-comment & insert a file to attach, CX-Supervisor throws an error saying that the function is not supported :shrug:


Quote

This can be achieved with the standard Microsoft object CDO.Message. This requires the use of the following VBScript:

set r = createobject ( "CDO.Message")
r.from = "automate3@orange.fr"
r.to = "Durand@eu.omron.com"
r.subject = "test-mail Cx supervisor"
r.TextBody = "alarm flag"
r.Configuration.fields.item ( "http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
r.Configuration.fields.item ( "http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.orange.fr"
r.configuration.fields.update
'r.addattachment ....... file here?
r.send


This script can be executed in a CX-Supervisor script.



All of the microsoft references to this contain the same script, but show the attachment working. I am sure I have used this in another VB script in another application.
There must be a reason the r.addattchement is commented out..??

I have another way to send attachments, but that also has issues as I cannot get the message body how I would like it... yet that is anyway :slydog:
0

#2
User is offline   lostcontrol 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 370
  • Joined: 27-May 09
  • Country:New Zealand
    New Zealand
Solved, thanks to MyOmron.com!!

It appears that I was using the .addattachment function incorrectly...

I was using:
r.addattachment = "C:\MyFile.txt"

Whereas I should of been using:
r.addattachment "C:\MyFile.txt"

The '=' was the bit that was hanging me up.
Now though, when I look back at the example (& probably some of the Microsoft examples), it does not have the '=' either... :hitit: :hitit:


Thanks to Jean-Pierre at MyOmron.com for spotting the simple oversight. :notworthy: :notworthy:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users