limpan0105
asked on
Create mail from file in Powerbuilder
I want to send mailaddresses from a file and open mailsession in Outlook
mailSession lmail_Ses
mailReturnCode lmail_RCode
mailMessage lmail_Msg
mailRecipient lmail_Recipient
FileOpen(ls_epostfil, StreamMode!, Read!, LockRead!, Replace!)
li_filkoll = FileRead(li_filenum,ls_epo ster)
IF li_filkoll < 1 THEN
MessageBox("Mail", "File failedl")
ELSE
// **** Create a mail session **
lmail_Ses = CREATE mailSession
// **** Log on to the session **
lmail_RCode = lmail_Ses.mailLogon(mailNe wSession!)
IF lmail_RCode <> mailReturnSuccess! THEN
MessageBox("Mail", 'Logon failed.')
ELSE
lmail_RCode = lmail_Ses.MailAddress()
IF lmail_RCode = mailReturnUserAbort! Then
MESSAGEBOX('', "User Cancelled send Mail")
ELSE
// **** Create Recipints ***
lmail_recipient.Address = ls_eposter
lmail_recipient.RecipientT ype = mailTo!
lmail_msg.Recipient[1] = lmail_recipient
lmail_Ses.MailAddress(lmai l_msg)
FileClose(li_FileNum)
IF lmail_RCode <> mailReturnSuccess! THEN
MessageBox("Mail", 'Addressing faild.')
ELSE
// **** Send the mail
lmail_RCode = lmail_Ses.MailSend()
IF lmail_RCode <> mailReturnSuccess! THEN
MessageBox("Mail", 'Sending mail failed.')
END IF
END IF
END IF
END IF
lmail_Ses.MailLogoff()
DESTROY lmail_Ses
END IF
mailSession lmail_Ses
mailReturnCode lmail_RCode
mailMessage lmail_Msg
mailRecipient lmail_Recipient
FileOpen(ls_epostfil, StreamMode!, Read!, LockRead!, Replace!)
li_filkoll = FileRead(li_filenum,ls_epo
IF li_filkoll < 1 THEN
MessageBox("Mail", "File failedl")
ELSE
// **** Create a mail session **
lmail_Ses = CREATE mailSession
// **** Log on to the session **
lmail_RCode = lmail_Ses.mailLogon(mailNe
IF lmail_RCode <> mailReturnSuccess! THEN
MessageBox("Mail", 'Logon failed.')
ELSE
lmail_RCode = lmail_Ses.MailAddress()
IF lmail_RCode = mailReturnUserAbort! Then
MESSAGEBOX('', "User Cancelled send Mail")
ELSE
// **** Create Recipints ***
lmail_recipient.Address = ls_eposter
lmail_recipient.RecipientT
lmail_msg.Recipient[1] = lmail_recipient
lmail_Ses.MailAddress(lmai
FileClose(li_FileNum)
IF lmail_RCode <> mailReturnSuccess! THEN
MessageBox("Mail", 'Addressing faild.')
ELSE
// **** Send the mail
lmail_RCode = lmail_Ses.MailSend()
IF lmail_RCode <> mailReturnSuccess! THEN
MessageBox("Mail", 'Sending mail failed.')
END IF
END IF
END IF
END IF
lmail_Ses.MailLogoff()
DESTROY lmail_Ses
END IF
What is happening now with the code? Any error?
ASKER
Sorry. I have all emailaddresses in a file and want to sent emails to all addresses and write a message to the recipients. I can´t get the addresses in to Outlook. It stops always and open a dialog window with all emailaddresses. Even if I choose a emailaddress in the dialog window the program stops, sending mail failed. When the emailaddresses are in outlook I want to write a message to the recipients before I sent it.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you very much, you made my day! The OLE solution was perfect.