Trying send mails and attachments via Outlook

We encourage new members to introduce themselves here. Get to know one another and share your interests.
rn@warner-it.com
Posts: 46
Joined: Mon Mar 04, 2019 4:41 pm

Trying send mails and attachments via Outlook

Post 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
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Trying send mails and attachments via Outlook

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Trying send mails and attachments via Outlook

Post 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
______________________
Johan Nel
Boshof, South Africa
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Trying send mails and attachments via Outlook

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Trying send mails and attachments via Outlook

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Trying send mails and attachments via Outlook

Post 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)
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
rn@warner-it.com
Posts: 46
Joined: Mon Mar 04, 2019 4:41 pm

Trying send mails and attachments via Outlook

Post by rn@warner-it.com »

Hi Chris,
Thanks form the Info will Try it all out.

Raymond
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Trying send mails and attachments via Outlook

Post 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.
______________________
Johan Nel
Boshof, South Africa
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Trying send mails and attachments via Outlook

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Trying send mails and attachments via Outlook

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply