PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 23 → [WD22] Start Outlook and hold it open
[WD22] Start Outlook and hold it open
Débuté par Michael Drechsel, 07 juin 2018 15:54 - 8 réponses
Posté le 07 juin 2018 - 15:54
Hallo,

I try to create am E-Mail with only a bodytext and open it in Outlook without sending the E-Mail (just like the iprintreport it does).

Is there any "outlookshow" function ??
Posté le 07 juin 2018 - 16:36
Hi Michael,

I use the code below for that. Works like a charm. It uses OLE instead of the WD mail functions.

PROCEDURE EmailSendMessageOutlookDotNet(LOCAL arrRecipients is array of string, LOCAL sSubject is string, sMessage is string, LOCAL arrAttachements is array of string) bResult is boolean myItem is object OLE dynamic myOlApp is object OLE dynamic myOlAccount is object OLE dynamic myOlAccounts is object OLE dynamic anAttachement is EmailAttach sRecipient is string sAttachement is string nOutlookAccount is int WHEN EXCEPTION IN myOlApp = new object OLE "Outlook.Application" myOlAccounts = myOlApp>>Session>>Accounts FOR i = 1 TO myOlApp>>Session>>Accounts>>Count //IF Lower(sOutlookAccount) = Lower(myOlApp>>Session>>Accounts>>Item(i)>>DisplayName) THEN nOutlookAccount = i BREAK //END END IF nOutlookAccount <= 0 THEN RESULT False END myOlAccount = myOlAccounts>>item(nOutlookAccount) // Trace(myOlAccount>>displayname) myItem = myOlApp>>CreateItem(olMailItem) FOR EACH sRecipient OF arrRecipients myItem>>Recipients>>Add(NoSpace(sRecipient)) END FOR EACH sAttachement OF arrAttachements IF fFileExist(CompleteDir(fTempPath()) + sAttachement) THEN myItem>>Attachments>>Add(CompleteDir(fTempPath()) + sAttachement) ELSE IF fFileExist(sAttachement) THEN myItem>>Attachments>>Add(sAttachement) END END END myItem>>BodyFormat = 2 // html // First display the email to get the users signature myItem>>Display() // then add the body/message myItem>>Subject = sSubject myItem>>HTMLBody = RTFToText(sMessage) + CR + myItem>>HTMLBody myItem>>SendUsingAccount(myOlAccount) IF myOlApp>>ActiveWindow <> Null THEN myOlApp>>ActiveWindow>>Activate END // Now send the email //myItem>>Send() bResult = True DO LogInfo(dbgInfo(dbgProcess),ExceptionInfo(errCode),ExceptionInfo(errMessage),TYPE_ERROR,NOT m_bSilent) END RESULT bResult
Posté le 07 juin 2018 - 16:53
Hi

another way of doing that (and it works with ALL email programs) is to prepare your email, than save it's SOURCE as an .eml file, and finally run a shellexecute on that file...

AFAIK, that's how pcsoft is doing it in the print preview, and it' takes only 2 lines of code.

Best regards
Posté le 20 juin 2018 - 09:55
Hello to you all and especial Fabrice,

I made an email message with: Email.Messsage="my text"; Email.Attach = .. etc.
Then I did an EmailBuild and at last:
ShellExecute("c:\ emp\MyEmail.eml")

It opens the email message (in Office 365) but it seams that it is a normal recieved email.
I can't send it.
What did I overlook?
Thanks in advance.
Posté le 20 juin 2018 - 10:07
Hi Frans,

I did some test years ago and afaik you have to add an extra line to the generated EML.
X-Unsent: 1
Posté le 20 juin 2018 - 10:28
Hello Arie,

THANKS. Perfect!!
Posté le 20 juin 2018 - 13:55
Hello to you all,

Still fighting with email.
The Email.Priority=emailHighPriority works perfect.

Found out that BCC only works with EmailBuildSource(emailOptionHeaderBcc)
This is not in the offline help. Only in the online.

At the moment I can't get working:

Email.ReturnReceipt=True
Email.DispositionNotification=True

Any ideas?
Thanks in advance.
Posté le 20 juin 2018 - 14:18
Hi Frans,

I did a lot of testing. Only Email.DispositionNotification=True works for me. The other one does not.

Best regards,

Aad
Posté le 20 juin 2018 - 14:26
Hi Aad,
Thanks for your fast reply.
Will send an email to pc-soft.
Perhaps we overlook something.
If wil reply if they have a solution.