These are chat archives for IndySockets/Indy
I Search,study and read all your Online Guide about my problem (Indy comp on Delphi) , but i dont find anything useful for me.
I'm a Delphi Dev , using indy 10.6 on Delphi 10.0.3
Now my problem [Deeper]:
My company have a net full of restrictions , i can't install a .dll on users outlook.exe [V.2016] , i can't intercept imap / pop / smtp / or nothing.
And then , the idea comes. (With Idea , i means my last chance to avoid my net restriction).
procedure TFrmMain.FormCreate(Sender: TObject); begin DragAcceptFiles(Handle, True); end;
With this Handler i allow my form to receive DragAndDrop Items.msg from Outlook 20016.
Drag From outlook -> To Desktop
From Desktop -> To My Form
procedure TFrmMain.WMDropFiles(var Msg: TMessage); var hDrop: THandle; FileCount: Integer; NameLen: Integer; I: Integer; S: string; begin hDrop:= Msg.wParam; FileCount:= DragQueryFile (hDrop , $FFFFFFFF, nil, 0); for I:= 0 to FileCount - 1 do begin NameLen:= DragQueryFile(hDrop, I, nil, 0) + 1; SetLength(S, NameLen); DragQueryFile(hDrop, I, Pointer(S), NameLen); end; DragFinish(hDrop); end;
Now that i've My
i open it inTidMessage.LoadFromFile(S,False);
Now , i take the Data i need (Subj / From / Body ) with this :
Var1:=Trim(TidMessage.From.Text); Var2:=DateToStr(TidMessage.Date)); Var3:=TidMessage.Subject; if TidMessage.Priority=mpLowest then Var4:=0; if TidMessage.Priority=mpLow then Var4:=1; if TidMessage.Priority=mpNormal then Var4:=2; if TidMessage.Priority=mpHighthen Var4:=3; if TidMessage.Priority=mpHighest then Var4:=4; Var5:=TidMessage.MsgId;
BUT everytime i try to take attachment (As i use to do with many of my TiDImap4)
for i := 0 to Messaggio.MessageParts.Count-1 do BEGIN CODE END
Everytime , messageparts.count = 0
Do you know what am i doing Wrong? Or maybe where i can found the solution or the concept i miss?
I'm Really sorry for my english , but it's not my native language and i try my best.
WM_DROPFILEShandler, when calling
S, DO NOT use
+1to include the null terminator. a null terminator is already implicitly included in the allocated memory but not counted by the length. You are allocating a 2nd null terminator and not removing it after populating
S, so you are actually passing
LoadFromFile(), and that can fail since the
#0would get treated as a character in the requested filename but doesn't exist in the actual file on disk. That being said, if you implement the
IDropTargetinterface in your Form and use
DragAcceptFiles()then you won't even need to drop emails onto your Desktop at all, you can drag the emails from Outlook directly to your Form instead.
MessagePartswould be 0 is if either 1) there really are no attachments in the email, 2) the email is malformed, or 3) the email not being parsed correctly. I'm leaning towards 3 in your case, but I'm only guessing since you didn't show the actual content of the email files you are trying to load.