Autor Beitrag
MagicTom
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

2000, XP Pro, 2003 Srv, 2003 SBS, Vista
D5, D7, D2005
BeitragVerfasst: Do 15.07.10 15:41 
Hallo,

ich habe ein Problem und hoffe es kann mir jemand helfen. Ich möchte gerne einen Quelltext aus einer Hilfedatei in Delphi benutzen, kann aber leider nicht so ganz den C# Code verstehen - Glaube ich ;-)

Der Original Quelltext sollte funktionieren, meiner tut`s nicht :-(

Quelltext aus der Hilfe:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
oFields = (Fields)oMessageItem2.Fields;
oMessageItem2.Subject = "Subject";
oFields.Item("IconNo").Value = 10;
oFields.Item("Received").Value = true;
oFields.Item("Priority").Value = DvMessagePriority.DvMsgPriorityImportant;
oFields.Item("SRFrom").Value = "Thomas.Tobit@tobit.com";
oFields.Item("SRTo").Value = "local.user@domain";
oFields.Item("SRFromDisplay").Value = "Tobit Thomas";
oFields.Item("Content").Value = "Body Text";
strAdr[0, 0] = "Thomas.Tobit0@tobit.com";
strAdr[1, 0] = "Thomas.Tobit1@tobit.com";
strAdr[2, 0] = "Thomas.Tobit2@tobit.com";
strAdr[3, 0] = "Thomas.Tobit3@tobit.com";
strAdr[0, 1] = "Thomas Tobit0";
strAdr[1, 1] = "Thomas Tobit1";
strAdr[2, 1] = "Thomas Tobit2";
strAdr[3, 1] = "Thomas Tobit3";
oFields.Item("To").Value = strAdr;
strAdr = null;
strAdr = new string[1, 2];
strAdr[0, 0] = "Thomas.Tobit4@tobit.com";
strAdr[0, 1] = "Thomas Tobit4";
oFields.Item("CC").Value = strAdr;
oMessageItem2.Attachments.Add(@"c:\testfile.txt", "Display name");
oMessageItem2.Save(DBNull.Value, DBNull.Value);
oAcc.Logoff();


Mein Quelltext:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
  oFields := IDispatch (oMsgItem2.Fields) as Fields;
  oMsgItem2.Subject := 'Subject';
  oFields.Item('IconNo').Value := 10;
  oFields.Item('Received').Value := True;
  oFields.Item('Priority').Value := DvMsgPriorityImportant;
  oFields.Item('SRFrom').Value := 'Thomas.Tobit@tobit.com';
  oFields.Item('SRTo').Value := 'Thomas.Test@test.de';
  oFields.Item('SRFromDisplay').Value := 'Tobit Thomas';
  oFields.Item('Content').Value := 'Body Text';
  VarTo := VarArrayCreate([0, 1, 0, 1], varVariant);
  VarTo[0, 0] := 'Thomas.Test@test.de';
  VarTo[0, 1] := 'Thomas Test';
  oFields.Item('To').Value := VarTo;
  VarCC := VarArrayCreate([0, 1, 0, 1], varVariant);
  VarCC[0, 0] := 'Thomas.Tobit4@tobit.com';
  VarCC[0, 1] := 'Thomas Tobit4';
  oFields.Item('Cc').Value := VarCC;
  oMsgItem2.Attachments.Add('c:\testfile.txt', 'Display name');
  oMsgItem2.Save(DvMsgSelEMail, 0);
  oAccount.Logoff();


Ich bekomme immer Exceptions, meisten Adresse 0 usw.

Danke im voraus!
Tom


Moderiert von user profile iconNarses: Topic aus Algorithmen, Optimierung und Assembler verschoben am Do 15.07.2010 um 16:00
uko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 220
Erhaltene Danke: 1

Win XP, VISTA, WIndows 7
Delphi 2007/2010 Prof
BeitragVerfasst: Do 15.07.10 15:47 
Was sagt denn der Debugger? Bei welcher Zeile kommt die Exception denn?

Uli
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Do 15.07.10 15:48 
Ich vermute mal das das Object nicht instanziert ist (CreateObject), deswegen Zugriffsfehler (ist aber Glaskugel)

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
MagicTom Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

2000, XP Pro, 2003 Srv, 2003 SBS, Vista
D5, D7, D2005
BeitragVerfasst: Do 15.07.10 16:09 
Hallo, und Danke schonmal!

Zum besseren Verständnis, hier der gesamte Quelltext: (Sorry!)

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
using DvApi32;
...

DavidAPIClass oApp;
Account oAcc;
Archive oArchive;
MessageItem2 oMessageItem2;
Fields oFields;
string[,] strAdr = new string[4, 2];

oApp = new DavidAPIClass();
oApp.LoginOptions = DvLoginOptions.DvLoginForceAsyncDuplicate;
oAcc = oApp.Logon("", "", "", "", "", "NOAUTH");

oArchive = oAcc.GetSpecialArchive(DvArchiveTypes.DvArchivePersonalIn);
oMessageItem2 = oArchive.CreateArchiveEntry(DvItemTypes.DvEMailItem);

oFields = (Fields)oMessageItem2.Fields;
oMessageItem2.Subject = "Subject";
oFields.Item("IconNo").Value = 10;
oFields.Item("Received").Value = true;
oFields.Item("Priority").Value = DvMessagePriority.DvMsgPriorityImportant;
oFields.Item("SRFrom").Value = "Thomas.Tobit@tobit.com";
oFields.Item("SRTo").Value = "local.user@domain";
oFields.Item("SRFromDisplay").Value = "Tobit Thomas";
oFields.Item("Content").Value = "Body Text";

strAdr[0, 0] = "Thomas.Tobit0@tobit.com";
strAdr[1, 0] = "Thomas.Tobit1@tobit.com";
strAdr[2, 0] = "Thomas.Tobit2@tobit.com";
strAdr[3, 0] = "Thomas.Tobit3@tobit.com";
strAdr[0, 1] = "Thomas Tobit0";
strAdr[1, 1] = "Thomas Tobit1";
strAdr[2, 1] = "Thomas Tobit2";
strAdr[3, 1] = "Thomas Tobit3";

oFields.Item("To").Value = strAdr;

strAdr = null;
strAdr = new string[1, 2];

strAdr[0, 0] = "Thomas.Tobit4@tobit.com";
strAdr[0, 1] = "Thomas Tobit4";

oFields.Item("CC").Value = strAdr;

oMessageItem2.Attachments.Add(@"c:\testfile.txt", "Display name");
oMessageItem2.Save(DBNull.Value, DBNull.Value);

oAcc.Logoff();
...
MagicTom Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

2000, XP Pro, 2003 Srv, 2003 SBS, Vista
D5, D7, D2005
BeitragVerfasst: Do 15.07.10 16:16 
@uko

Sorry, hatte ich in der Eile übersehen:

Zeile 17

Danke
Tom
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Do 15.07.10 17:24 
user profile iconMagicTom hat folgendes geschrieben Zum zitierten Posting springen:
@uko

Sorry, hatte ich in der Eile übersehen:

Zeile 17

Danke
Tom


Das ist aber eine Leerzeile. :lol:

_________________
Es gibt 10 Gruppen von Menschen: diejenigen, die das Binärsystem verstehen, und die anderen.
der organist
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 467
Erhaltene Danke: 17

WIN 7
NQC, Basic, Delphi 2010
BeitragVerfasst: Do 15.07.10 18:25 
user profile iconDude566 hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconMagicTom hat folgendes geschrieben Zum zitierten Posting springen:
@uko

Sorry, hatte ich in der Eile übersehen:

Zeile 17

Danke
Tom


Das ist aber eine Leerzeile. :lol:


im oberen fhelrefahten Quelltext aber nich :)

_________________
»Gedanken sind mächtiger als Waffen. Wir erlauben es unseren Bürgern nicht, Waffen zu führen - warum sollten wir es ihnen erlauben, selbständig zu denken?« Josef Stalin
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 16.07.10 13:05 
Ist Items ein Array oder Array-Property? Wenn ja, müssten es eckige Klammern sein.

Ach ja: Nicht so viele Informationen wie eine Fehlermeldung oder die gewünschte Aufgabe nennen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
MagicTom Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

2000, XP Pro, 2003 Srv, 2003 SBS, Vista
D5, D7, D2005
BeitragVerfasst: Fr 16.07.10 13:49 
Hallo nochmal,

Danke für eure Antworten, aber das Problem waren tatsächlich die beiden VarArrays...

Scheinbar habe ich das erst auf den 84sten Blick gerafft! Nun funktioniert es <bg>

Tom