[Migrated content. Thread originally posted on 07 February 2011]
Has anyone accomplished creating a program that will generate an email with an attachement using GMAIL from a cobol progarm? If so, are you willing to share your code. I presently have a program that uses windows email. We pass the email address and attachment path and the program creates an email with the attachment and calls microsoft email and sends the message. We want to do the same with GMAIL.Page 1 / 1
[Migrated content. Thread originally posted on 07 February 2011]
Has anyone accomplished creating a program that will generate an email with an attachement using GMAIL from a cobol progarm? If so, are you willing to share your code. I presently have a program that uses windows email. We pass the email address and attachment path and the program creates an email with the attachment and calls microsoft email and sends the message. We want to do the same with GMAIL.The COBOL code equivalent of their example is:
$set ilusing"System.Web.Mail"
$set ilusing"GmailHelper"
program-id. Program1 as "ConsoleApplication1.Program1".
data division.
working-storage section.
*>Use the GmailMessage object to create and send your message
01 gmailMsg type RC.Gmail.GmailMessage.
01 attachment type MailAttachment.
01 mailMessageObject type MailMessage.
procedure division.
*> Send a message with one line of code
invoke type RC.Gmail.GmailMessage::SendFromGmail("username", "password", "toAddress@gmail.com", "subject", "message body")
*> Send a message with one line of code with a MailMessage object
invoke type RC.Gmail.GmailMessage::SendMailMessageFromGmail("username", "password", mailMessageObject)
set gmailMsg to new type RC.Gmail.GmailMessage("username", "password")
set gmailMsg::To to "RCcode@gmail.com"
set gmailMsg::From to "fromAddress@gmail.com"
set gmailMsg::Subject to "C# Test Message"
set gmailMsg::Body to "Test body"
set attachment to new type System.Web.Mail.MailAttachment("c:\\testfile.txt")
invoke gmailMsg::Attachments::Add(attachment)
invoke gmailMsg::Send()
goback.
end program Program1.
[Migrated content. Thread originally posted on 07 February 2011]
Has anyone accomplished creating a program that will generate an email with an attachement using GMAIL from a cobol progarm? If so, are you willing to share your code. I presently have a program that uses windows email. We pass the email address and attachment path and the program creates an email with the attachment and calls microsoft email and sends the message. We want to do the same with GMAIL. $set ilusing"System.Net"
$set ilusing"System.Net.Mail"
program-id. SendMailCobol as "SendMailCobol".
data division.
working-storage section.
01 mailaddr Type MailAddress.
01 mailmsg Type MailMessage.
01 client Type SmtpClient.
procedure division.
set mailmsg to new MailMessage()
set mailaddr to new MailAddress("somename@domain.com", "John Doe")
invoke mailmsg::To::Add(mailaddr)
set mailmsg::From to new MailAddress("youremail@gmail.com", "Your Name")
set mailmsg::Subject to "Sent from Visual COBOL"
set mailmsg::Body to "Your Message Text"
set mailmsg::IsBodyHtml to false
*> Add an attachment to the Attachments collection of the mail message object
invoke mailmsg::Attachments::Add(new Attachment("C:\\yourfile.pdf"))
set client to new SmtpClient()
set client::Credentials to new NetworkCredential("youremail@gmail.com", "yourpassword")
set client::Port to 587
set client::Host to "smtp.gmail.com"
set client::EnableSsl to true
try
invoke client::Send(mailmsg)
catch
display exception-object::Message
end-try
goback.
end program SendMailCobol.Make sure you have a gmail account established if going thru the gmail smtp server. If using another smtp server, then you would need to change the host, port, and EnableSSL properties accordingly. If you need to add more than one attachment then call the Add method for each attachment.
[Migrated content. Thread originally posted on 07 February 2011]
Has anyone accomplished creating a program that will generate an email with an attachement using GMAIL from a cobol progarm? If so, are you willing to share your code. I presently have a program that uses windows email. We pass the email address and attachment path and the program creates an email with the attachment and calls microsoft email and sends the message. We want to do the same with GMAIL.while these fine examples are using Visual COBOL, I suppose you are looking for one using Extend? Try to do the translation, if you get stuck, post your work here and we can see if we can work this out together.
[Migrated content. Thread originally posted on 07 February 2011]
Has anyone accomplished creating a program that will generate an email with an attachement using GMAIL from a cobol progarm? If so, are you willing to share your code. I presently have a program that uses windows email. We pass the email address and attachment path and the program creates an email with the attachment and calls microsoft email and sends the message. We want to do the same with GMAIL.[Migrated content. Thread originally posted on 07 February 2011]
Has anyone accomplished creating a program that will generate an email with an attachement using GMAIL from a cobol progarm? If so, are you willing to share your code. I presently have a program that uses windows email. We pass the email address and attachment path and the program creates an email with the attachment and calls microsoft email and sends the message. We want to do the same with GMAIL.I need to compile this program in AcuCobol, can you help-me
[Migrated content. Thread originally posted on 07 February 2011]
Has anyone accomplished creating a program that will generate an email with an attachement using GMAIL from a cobol progarm? If so, are you willing to share your code. I presently have a program that uses windows email. We pass the email address and attachment path and the program creates an email with the attachment and calls microsoft email and sends the message. We want to do the same with GMAIL.Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.