Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
#VisualCOBOL
#nativecobol
#COBOL
#attaching
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
I think I used marshallsoft from an mf cobol program over 15 years ago to mass send email for an email news service. Worked very well.
NEXT QUESTION... how to create PDFs and attach them too?
It would be great to be able to create PDFs and send an email (to invoice clients etc) all from a visual cobol app.
Thanks,
Linden
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
I think I used marshallsoft from an mf cobol program over 15 years ago to mass send email for an email news service. Worked very well.
NEXT QUESTION... how to create PDFs and attach them too?
It would be great to be able to create PDFs and send an email (to invoice clients etc) all from a visual cobol app.
Thanks,
Linden
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
The following is an example of sending an email with an attachment using the .NET SmtpClient class. This allows you to specify the host name and port to use as well as many other properties. This example uses an async send method.
$set ilusing"System.Net"
$set ilusing"System.Net.Mail"
$set ilusing"System.Net.Mime"
$set ilusing"System.Threading"
$set ilusing"System.ComponentModel"
class-id sendsmtpmail.SimpleAsynchronousExample.
working-storage section.
01 mailSent condition-value static value false.
method-id SendCompletedCallback static private (sender as object, e as type AsyncCompletedEventArgs).
*> Get the unique identifier for this asynchronous operation.
declare token as string = e::UserState as string
if e::Cancelled
invoke type Console::WriteLine("[{0}] Send canceled.", token)
end-if
if e::Error not = null
invoke type Console::WriteLine("[{0}] {1}", token, e::Error::ToString())
else
invoke type Console::WriteLine("Message sent.")
end-if
set mailSent to true
goback.
end method.
method-id Main public static (args as string occurs any)
. *> The SMTP host name is passed as a string in the constructor in this example
declare client as type SmtpClient = new SmtpClient("mail.myserver.com")
*> Specify the e-mail sender.
*> Create a mailing address
declare #from as type MailAddress = new MailAddress("chris.glazier@microfocus.com",
"Chris Glazier", type System.Text.Encoding::UTF8)
*> Set destinations for the e-mail message.
declare #to as type MailAddress = new MailAddress("chris.glazier@microfocus.com")
*> Specify the message content.
declare #message as type MailMessage = new MailMessage(#from, #to)
set #message::Body = "This is a test e-mail message sent by an application. "
& type Environment::NewLine
set #message::BodyEncoding = type System.Text.Encoding::UTF8
set #message::Subject = "test message 1"
set #message::SubjectEncoding = type System.Text.Encoding::UTF8
*> Set the method that is called back when the send operation ends.
invoke #message::Attachments::Add(new Attachment("C:\\temp\\testfile.txt"))
attach method self::SendCompletedCallback to client::SendCompleted
*> The userState can be any object that allows your callback
*> method to identify this send operation.
*> For this example, the userToken is a string constant.
declare userState as string = "test message1"
set client::Credentials = type CredentialCache::DefaultNetworkCredentials
invoke client::SendAsync(#message, userState)
invoke type Console::WriteLine("Sending message... press c to cancel mail. Press any other key to exit.")
declare answer as string = type Console::ReadLine
*> If the user canceled the send, and mail hasn't been sent yet,
*> then cancel the pending operation.
if answer::StartsWith("c") and mailSent = false
invoke client::SendAsyncCancel
end-if
*> Clean up.
invoke #message::Dispose
invoke type Console::WriteLine("Goodbye.")
goback.
end method.
end class.
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Hello Chris Good day, I am testing your solution, but I generate errors in the definition, I am running under net framework 4.6, I am not clear if I am using a wrong version of netframework, muchas gracias Chris 
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Hello Chris Good day, I am testing your solution, but I generate errors in the definition, I am running under net framework 4.6, I am not clear if I am using a wrong version of netframework, muchas gracias Chris 
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
good day Get the sending of emails from the SMTP server using code in managed cobol. How can I make the call of said code from a code in native cobol from which I will send the recipients, subject and content of the electronic mail. As the link area used in native cobol, thanks and blessings for your valuable collaboration
this is the code in cobol menaged
$set ilusing"System.Net"
$set ilusing"System.Net.Mail"
program-id. SendMailCobol as "SendMailCobol".
data division.
working-storage section.
01 DIRECCION TYPE MailAddress.
01 MAILCOPY TYPE MailAddressCollection.
01 MENSAJE TYPE MailMessage.
01 CUENTA TYPE SmtpClient.
77 CONCOPIA PIC X(55) VALUE "soporte_sistemas@croydon.com.co; mgalvis@croydon.com.co".
77 DESTINATARIOS PIC x(31) VALUE "soporte_sistemas@croydon.com.co".
77 CONTENIDO PIC x(300) VALUE "mensaje de correo electronico enviado desde el sistema AURORA. Por favor no responder a este mensaje".
77 TITULO PIC x(100) VALUE "Prueba de envio de correo electronico AURORA".
procedure division.
*> CREA MENSAJE Y ALISTA LA COLA DE ENVIO
SET MENSAJE TO NEW MailMessage()
SET DIRECCION TO NEW MailAddress(DESTINATARIOS)
SET MAILCOPY TO NEW MailAddressCollection()
INVOKE MENSAJE::To::Add(DIRECCION)
*> CREA CONTENIDO, REMITENTE, Y ASUNTO DEL EMAIL
SET MENSAJE::From to new MailAddress("sistemaaurora@croydon.com.co", "Sistema AURORA")
SET MENSAJE::Subject to TITULO
SET MENSAJE::Body to CONTENIDO
SET MENSAJE::IsBodyHtml to false
*> ARCHIVO ADJUNTO PARA ENVIO
INVOKE MENSAJE::Attachments::Add(NEW Attachment("F:\\prueba\\attach.jpg"))
*> CONFIGURACION DE LA CUENTA Y CREDENCIALES
SET CUENTA TO NEW SmtpClient()
SET CUENTA::Credentials TO NEW NetworkCredential("sistemaaurora@croydon.com.co", "********")
SET CUENTA::Port TO 25
SET CUENTA::Host TO "smtp.croydon.com.co"
SET CUENTA::EnableSsl TO FALSE
TRY
INVOKE CUENTA::Send(MENSAJE)
CATCH
DISPLAY exception-object::Message
END-TRY
GOBACK.
END PROGRAM SendMailCobol.
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
good day Get the sending of emails from the SMTP server using code in managed cobol. How can I make the call of said code from a code in native cobol from which I will send the recipients, subject and content of the electronic mail. As the link area used in native cobol, thanks and blessings for your valuable collaboration
this is the code in cobol menaged
$set ilusing"System.Net"
$set ilusing"System.Net.Mail"
program-id. SendMailCobol as "SendMailCobol".
data division.
working-storage section.
01 DIRECCION TYPE MailAddress.
01 MAILCOPY TYPE MailAddressCollection.
01 MENSAJE TYPE MailMessage.
01 CUENTA TYPE SmtpClient.
77 CONCOPIA PIC X(55) VALUE "soporte_sistemas@croydon.com.co; mgalvis@croydon.com.co".
77 DESTINATARIOS PIC x(31) VALUE "soporte_sistemas@croydon.com.co".
77 CONTENIDO PIC x(300) VALUE "mensaje de correo electronico enviado desde el sistema AURORA. Por favor no responder a este mensaje".
77 TITULO PIC x(100) VALUE "Prueba de envio de correo electronico AURORA".
procedure division.
*> CREA MENSAJE Y ALISTA LA COLA DE ENVIO
SET MENSAJE TO NEW MailMessage()
SET DIRECCION TO NEW MailAddress(DESTINATARIOS)
SET MAILCOPY TO NEW MailAddressCollection()
INVOKE MENSAJE::To::Add(DIRECCION)
*> CREA CONTENIDO, REMITENTE, Y ASUNTO DEL EMAIL
SET MENSAJE::From to new MailAddress("sistemaaurora@croydon.com.co", "Sistema AURORA")
SET MENSAJE::Subject to TITULO
SET MENSAJE::Body to CONTENIDO
SET MENSAJE::IsBodyHtml to false
*> ARCHIVO ADJUNTO PARA ENVIO
INVOKE MENSAJE::Attachments::Add(NEW Attachment("F:\\prueba\\attach.jpg"))
*> CONFIGURACION DE LA CUENTA Y CREDENCIALES
SET CUENTA TO NEW SmtpClient()
SET CUENTA::Credentials TO NEW NetworkCredential("sistemaaurora@croydon.com.co", "********")
SET CUENTA::Port TO 25
SET CUENTA::Host TO "smtp.croydon.com.co"
SET CUENTA::EnableSsl TO FALSE
TRY
INVOKE CUENTA::Send(MENSAJE)
CATCH
DISPLAY exception-object::Message
END-TRY
GOBACK.
END PROGRAM SendMailCobol.
Good day please someone has knowledge or has an example of sending email by defining an SMTP server and attaching a file native Cobol, Many thanks for your collaboration
You would need to compile your managed code as a class and register for use as a COM server. You would either modify your program to use class and methods instead of program-id or create a class wrapper and CALL your existing program from within it.
Take a look at the article here:





Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
OKSorry, our virus scanner detected that this file isn't safe to download.
OK