Welcome! Log In Create A New Profile

Advanced

[WD22] Start Outlook and hold it open

Posted by Michael Drechsel 
Michael Drechsel
[WD22] Start Outlook and hold it open
June 07, 2018 03:54PM
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 ??



Edited 1 time(s). Last edit at 06/07/2018 03:55PM by Michael Drechsel.
Arie
Re: [WD22] Start Outlook and hold it open
June 07, 2018 04:36PM
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
Fabrice Harari
Re: [WD22] Start Outlook and hold it open
June 07, 2018 04:53PM
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
Frans
Re: [WD22] Start Outlook and hold it open
June 20, 2018 09:55AM
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:\temp\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.
Arie
Re: [WD22] Start Outlook and hold it open
June 20, 2018 10:07AM
Hi Frans,

I did some test years ago and afaik you have to add an extra line to the generated EML.
X-Unsent: 1
Frans
Re: [WD22] Start Outlook and hold it open
June 20, 2018 10:28AM
Hello Arie,

THANKS. Perfect!!
Frans
Re: [WD22] Start Outlook and hold it open
June 20, 2018 01:55PM
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.
Aad Gouka
Re: [WD22] Start Outlook and hold it open
June 20, 2018 02:18PM
Hi Frans,

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

Best regards,

Aad
Frans
Re: [WD22] Start Outlook and hold it open
June 20, 2018 02:26PM
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.
Solved
September 12, 2018 06:28PM
Hello Aad and Arie,


Did send a little project to Pc-Soft. Initially they said that it was a bug in their software. Two minutes later I got an answer. thumbs up
These two options only work when there is a sender specified.
So this wil do the job: Email.sender="MyEmail@Yahoo.com"

Regards Frans



Edited 1 time(s). Last edit at 09/12/2018 06:29PM by Frans.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: