Link to home
Create AccountLog in
Avatar of limpan0105
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_eposter)
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(mailNewSession!)
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.RecipientType = mailTo!
lmail_msg.Recipient[1] = lmail_recipient
lmail_Ses.MailAddress(lmail_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
Avatar of Harish Varghese
Harish Varghese
Flag of India image

What is happening now with the code? Any error?
Avatar of limpan0105
limpan0105

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
Avatar of Harish Varghese
Harish Varghese
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thank you very much, you made my day! The OLE solution was perfect.