xsharp.eu • Trying send mails and attachments via Outlook - Page 2
Page 2 of 3

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 4:27 pm
by rn@warner-it.com
Hi Chris,
Currently with all and I find it cumbersome because I have to scroll up and down to find the Methods.

Chris I did not quite understand what I should exactly do to solve my outlook problem.
I just posted Wolfgang that TRY shows an error. This is code that is currently working. Only when I add the Outlook:interop I then get the erros and I have a lot of Try and catch routine in my source code.

Regards,
Raymond

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 4:31 pm
by wriedmann
Hi Raymond,

it seems I'm ways too stupid to explain what your problem really is.

Maybe it is too much to TRY to put

Code: Select all

catch oEx as System.Exception
instead of

Code: Select all

catch oEx as Exception
in your code?
Wolfgang

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 4:33 pm
by lumberjack
Hi Wolfgang,
wriedmann wrote:Hi Raymond,
please read my message!
The compile error message says it clearly: the Microsoft.Office.Interop.Outlook.Exception class cannot be used with a catch statement. Therefore you need to fully qualify it as

Code: Select all

System.Execption
He does have System.Excepton

Don't you mean his CATCH statement should be:

Code: Select all

CATCH oEx AS Microsoft.Office.Interop.Outlook.Exception

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 4:35 pm
by wriedmann
Hi Raymond,
unfortunately it seems you need a full explanation and I'm not experienced enough to do that.

Microsoft has put a class called Exception in the Microsoft.Office.Interop.Outlook namespace, and if you include that interop, the compiler takes that class instead of the needed System.Exception class.

Therefore, if you include the interop in your application, you NEED to specify the fully qualified class name.

Maybe Vulcan has another sequence, but IMHO the X# compiler is right here.

Wolfgang

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 4:37 pm
by wriedmann
Hi Johan,

the compiler is taking the exception class from the interop assembly, and that class cannot be used in the catch statement.

When I tried to compile the code on my machine, it gave exactly the same error until I added the fully qualified class name.

Wolfgang

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 5:46 pm
by Chris
Hi Rymond,

Ah, I understand now, it's just that you need to compile the app first once. When you do that, then you should be able to use right-click for the GoTo Definition option to appear. Btw, you can also put the editor cursor on the method you want to go to its definition and press Alt+Right button, this searches by text and should get you to the method. Also you can use Alt + Left key for returning back.

As for the compiler error, just change the code

CATCH ex AS exception

to

CATCH ex AS System.Exception

(there was a typo earlier)

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 6:10 pm
by rn@warner-it.com
Hi Chris,
Thanks form the Info will Try it all out.

Raymond

Trying send mails and attachments via Outlook

Posted: Sat Mar 16, 2019 9:03 pm
by lumberjack
Guys,
I think we sometimes (see how we battled with Jeff) don't have the full picture.

I had the complete file and I believe what happened was this.
The Vulcan code was:

Code: Select all

USING Microsoft.Office.Interop
However, in the file as was send to me it had:

Code: Select all

USING Microsoft.Office.Interop.Excel // etc.
I make my assumption because there were a lot of commented lines like:

Code: Select all

LOCAL oApp AS ApplicationClass
//LOCAL oApp AS Excel.ApplicationClass
Hence, in the "original" code, there was no way the compiler could get confused with which Exception to use. I think both Vulcan and X# treated it the same, there was however a difference how the USING statement was defined.

Raymond, don't see this as directed against you. I just know from experience, my own Vulcan code compiled in 99% of cases as is, except where X# introduced something more strict, or highlighted a "bug" in Vulcan or where I had my own #command to emulate a feature that was not supported in Vulcan but was now standard in X#. Had to remove my # command and slightly adapt code to adhere to the X# implementation. One I can think of now was my #command around PROPERTY xxx AS INT GET SET y, slight difference in how I did it and how it was implemented in X#.

Johan
PS: Please check this and let us know the result.

Trying send mails and attachments via Outlook

Posted: Sun Mar 17, 2019 11:21 am
by robert
Raymond,

Make sure that the "bitness" of your app and outlook match: If you have a 32 bits version of outlook then you must also use a 32 bits (x86) version of your app. If your outlook is 64 bits then you will also need a 64 bits version of your app.

Robert

Trying send mails and attachments via Outlook

Posted: Sun Mar 17, 2019 11:51 am
by wriedmann
Hi Robert,
Fortunately you can overcome the bitness problem with COM.
My sample works in 64 bit mode, and my Outlook 2010 is 32 bit.
And COM is the only possibility to send emails through Outlook 64 bit from VO Applications.
Wolfgang