Citect MailSend() with attachment fails

IainH

Member
Join Date
Jul 2008
Location
Sussex
Posts
44
I am trying to send emails from a Vijeo Citect V7.20 project using the MailSend() function. However, when I try to attach a file to the email, the MailSend() function always returns a General MAPI Error (MAPI_E_FAILURE).

I can use the contents of the file as the body of the message, but, as it can be quite large, I would prefer to send it as an attachment.

I am using Outlook Express as that is available with the OS.

Is there any known solution?


Iain
 
I was able to do this by using some VBA code. which didn't require a running email client. Found it on a MSACCESS (Utteraccess I think) forum. will see if i can dig it up.
 
I was able to do this by using some VBA code. which didn't require a running email client. Found it on a MSACCESS (Utteraccess I think) forum. will see if i can dig it up.

Thanks, it's worth a try.

However, the email client is not running, the MailSend() function accesses it's functionality whe required to send an email.

I have read that it is a confirmed problem with Citect V7.0 and that there may even be a hotfix for V7.0r3?

Iain
 
I am trying to send emails from a Vijeo Citect V7.20 project using the MailSend() function. However, when I try to attach a file to the email, the MailSend() function always returns a General MAPI Error (MAPI_E_FAILURE).

I can use the contents of the file as the body of the message, but, as it can be quite large, I would prefer to send it as an attachment.

I am using Outlook Express as that is available with the OS.

Is there any known solution?


Iain

We gave up in the end with the in built Citect Mail functions, they are pretty flaky using MAPI, as you are discovering. But is it actually finding the attachment file successfully ?

Can you not get authenticated SMTP access, its much easier than relying on Outlook express....

We sued a third party application in the end but I guess you are not looking for suggestions that way.
 
We gave up in the end with the in built Citect Mail functions, they are pretty flaky using MAPI, as you are discovering. But is it actually finding the attachment file successfully ?

Can you not get authenticated SMTP access, its much easier than relying on Outlook express....

We sued a third party application in the end but I guess you are not looking for suggestions that way.

Ideally, I would like to use the built in Citect Mail functions - this is a simple add-on to an existing product that would give us regular updates of the machine status.

I'm reluctant to re-invent the wheel just to make it go round!

Iain
 
Create a VBA Code item in Citect.

Option Explicit
'Values 8, 9, 10, And 13 convert To
'backspace, tab, linefeed, And carriage return characters, respectively.


'*****************************************************************
'*****************************************************************
'* CDO.Messsage
'***********Send Email Without warnings***************************
'* Variables: sendTo - list of recipients
'* Body - text to display in email
'* Sender = "Your Sender"
'* smtpServer = "10.29.127.1"
'* smtpServer = 25
'* To add attachments use this line
'* .AddAttachment "c:\temp\readme.txt"
'*****************************************************************
'*****************************************************************

Public Sub sendCDOEmail(sendTo As string,Body As string, Attachment As string)
On Error Resume Next

Dim myMail As Object

'Create Object
Set myMail = CreateObject("CDO.Message")

'Create Email
myMail.Subject = "Your Subject"
myMail.From = "Your From"
myMail.To = sendTo
myMail.TextBody = body
myMail.AddAttachment Attachment

'**********************************
'** Configure Remote smtp server **
'**********************************
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.29.127.1"
'Server port
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= 25
myMail.Configuration.Fields.Update
'**End Configure Remote smtp server**

'Send it
myMail.Send

Set myMail = Nothing

End Sub

Call this code from cicode using the VBA call cicode functions eg
VbCallRun(VbCallOpen("sendCDOEmail", sMobile,smessage))
I was sending the email to a email to SMS server sMobile would be the emaill address
 
Last edited:
Ideally, I would like to use the built in Citect Mail functions - this is a simple add-on to an existing product that would give us regular updates of the machine status.

I'm reluctant to re-invent the wheel just to make it go round!

Iain

Are these message going outside of the building or just internal, if external SMTP is the much better way to go.

Is this an existing bit of code or are you modifying to add the attachment ?

Have you run the code in debug to check its getting the attachment file names etc. correctly ?

Is the mail even getting to Outlook express ? I remember when we used it i had to run some weird script outside of Citect to make sure Outlook was sending the message.

Just a few thoughts......
 

Similar Topics

Hello, I have a running project on Citect v5.42 and simatic net v6.4 I have created a new spare PC and loaded all software like Citect, station...
Replies
0
Views
68
Hello everyone, In a factory where we installed Citect 7.20 the computer began to show the first signs of end of life. They never considered...
Replies
0
Views
73
I have a running backup of Citect and plc and I want to make a spare PC station so I have installed the win XP and somatic net v6.0 and import the...
Replies
3
Views
121
I am trying to display a variable within a cicode function onto a graphics page. This function queries a SQL database. I can get the value onto a...
Replies
3
Views
288
Looking for some help with the connection issue between Citect 2018 and Top Server v6 for Opto22. I’m setting all this up to communicate with some...
Replies
0
Views
120
Back
Top Bottom