We want to set the account under which the mailitem is to be sent.
modify hMail, @SendUsingAccount, hAccount
But the command doesnt't work, the default account is used.
Example:
We have several accounts in Outlook and we want to use another account than the default -> notthedefault@xyz.com
This VB-Example works:
Private Sub Command1_Click()
Dim oAccount As Outlook.account 'display all accounts
For Each oAccount In Application.Session.Accounts
MsgBox (oAccount.SmtpAddress)
Next
For Each oAccount In Application.Session.Accounts
'send mail with another account, not with the default
If oAccount.SmtpAddress = "notthedefault@xyz.com" Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "VB: SendUsingAccount"
oMail.Recipients.Add ("reciptient@zzz.com")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub
But the Acu-Example doesn't work, the command SendUsingAccount is inefficient:
*-----------------------------------------------------------------
main section.
*-----------------------------------------------------------------
m-anfang.
initialize hAppOutlooks.
move zero to wh-ol-ind.
*
create application of outlook handle in hAppOutlook
*
modify hAppOutlook, @getnamespace("MAPI")
giving hNameSpace
inquire hNameSpace, @Accounts
in hAccounts
inquire hAccounts, @Count
in wh-olkonten-anz
*
if wh-olkonten-anz > 1
* ---- display all accounts -> OK -----------------------------
perform varying wh-ol-ind from 1 by 1
until wh-ol-ind > wh-olkonten-anz
modify hAccounts, @item(wh-ol-ind)
giving hAccount
inquire hAccount, @SmtpAddress
in wh-olkonto-email
display message box wh-olkonto-email
destroy hAccount
end-perform
* ---- use a not default account -> problem -------------------
perform varying wh-ol-ind from 1 by 1
until wh-ol-ind > wh-olkonten-anz
modify hAccounts, @item(wh-ol-ind)
giving hAccount
inquire hAccount, @SmtpAddress
in wh-olkonto-email
if wh-olkonto-email = "notthedefault@xyz.com"
display message box "Found:", wh-olkonto-email
modify hAppOutlook, @createitem(0)
giving hMail
modify hMail, @to, "reciptient@zzz.com"
modify hMail, @Subject, "Acu: SendUsingAccount"
* -----------------------this command doesn't work ------------
modify hMail, @SendUsingAccount, hAccount
* -------------------------------------------------------------
modify hMail, @send()
destroy hMail
end-if
destroy hAccount
end-perform
end-if.
destroy hAccounts.
destroy hNameSpace.
destroy hAppOutlook.
m-ausis.
goback.
Who can help me?
#COBOL
#OutlookRedemptionMapiLandSecurityManagerEmail
#ThinClient
#ACUCOBOL9.2.1
#AcuCobol