xsharp.eu • Harbour dialect error XS1510 A REF or OUT value must be an assignable variable
Page 1 of 1

Harbour dialect error XS1510 A REF or OUT value must be an assignable variable

Posted: Wed Jun 21, 2023 2:30 am
by RolWil
Hello XSharp sleuths;
I have a library with common functions. In this case, I'm adding a function to send emails; my pervious post regarding using Outlook eened up 'working; but not as I had wanted; I wanted the email to be created in the Outlook user's 'Drafts' folder; I changed the code and have it working no problem in native c# .Net in VS. But then I tried to bringing it over to my Harbour dialect project and am getting error:
"XS1510 A REF or OUT value must be an assignable variable " on the line with

Code: Select all

mail := (Outlook.MailItem) 
 oApp:CreateItemFromTemplate(@"E:AppsHarborClipperTargetDataTestsOutlookTemplatesMicheledefault.oft, folder)
in the code below. I'm assuming the issue is the 'folder' object I'm passing.

The project dialect is Harbour; I’ve added the following references:
XSharp.Core
XSharp.RT
Microsoft.Office.Interop.Outlook

I have:

Code: Select all

using Outlook := Microsoft.Office.Interop.Outlook
using System.Runtime.InteropServices     

FUNCTION SendEmail() AS VOID  
            
            LOCAL oApp AS Outlook.Application
            oApp := Outlook.Application{}

            LOCAL folder AS Outlook.Folder
            folder := (Outlook.Folder) oApp:ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts)

            LOCAL mail AS Outlook.MailItem
            mail := (Outlook.MailItem) oApp:CreateItemFromTemplate(@"E:AppsHarborClipperTargetDataTestsOutlookTemplatesMicheledefault.oft", folder)
            mail:Subject := "testing 123"

    RETURN
Thanks for any tips.

Harbour dialect error XS1510 A REF or OUT value must be an assignable variable

Posted: Wed Jun 21, 2023 5:38 am
by robert
Roland,
Remove the "@" character in front of the string.
That character is needed in C# but not in X#.

Robert

Harbour dialect error XS1510 A REF or OUT value must be an assignable variable

Posted: Wed Jun 21, 2023 3:17 pm
by RolWil
Thanks Robert, that was indeed the problem!

I must say, I am grateful that you folks have developed XSharp and continue to do so and support it so well. Many thanks,

Cheers
Roland