Hi,
ich habe hier nen kleines Problem. Ich habe vor mir ein Programm zu schreiben mit dem ich "Vorlagen" in
das Fenster "Neue Nachricht" automatisch einfügen kann.
Das klappt ja soweit auch wenn zum Bsp. beim Eingabe feld des Cc-Empfängers folgendes angegeben ist:
Quelltext
1:
| <INPUT type="text" name="MsgCc"......value=""> |
Doch leider ist da nicht
name sondern
id angegeben. Also:
Quelltext
1:
| <INPUT type="text" id="MsgCc"......value=""> |
Und genau damit habe ich das Problem. Es wird einfach nicht das Feld ausgefüllt.
Habe jetzt schon verzweifelt gesucht, aber leider noch nichts gefunden.
Hier mal das Programm:
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: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Forms, MSHTML, SHDocVw, StdCtrls, ShellAPI, Classes, Controls;
const IDS_WNDTITLE = 'Unbenannt -- Nachricht - Microsoft Internet Explorer'; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1; Msg: TMessage;
implementation
{$R *.dfm}
procedure SwitchToThisWindow(h1: hWnd; x: bool); stdcall; external user32 Name 'SwitchToThisWindow';
function FindWindowByTitle(WindowTitle: string): Hwnd; var NextHandle: Hwnd; NextTitle: array[0..260] of char; begin NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST); while NextHandle > 0 do begin GetWindowText(NextHandle, NextTitle, 255); if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then begin Result := NextHandle; Exit; end else NextHandle := GetWindow(NextHandle, GW_HWNDNEXT); end; Result := 0; end;
procedure TForm1.Button1Click(Sender: TObject); var ShellWindow: IShellWindows; WB: IWebbrowser2; spDisp: IDispatch; IDoc1: IHTMLDocument2; Document: Variant; k, m: Integer; ovElements: OleVariant; i: Integer; begin SwitchToThisWindow(FindWindowByTitle(IDS_WNDTITLE), True); ShellWindow := CoShellWindows.Create; for k := 0 to ShellWindow.Count do begin spDisp := ShellWindow.Item(k); if spDisp = nil then Continue; spDisp.QueryInterface(iWebBrowser2, WB);
if WB <> nil then begin WB.Document.QueryInterface(IHTMLDocument2, iDoc1); if iDoc1 <> nil then begin WB := ShellWindow.Item(k) as IWebbrowser2; begin Document := WB.Document;
for m := 0 to Document.forms.Length - 1 do begin ovElements := Document.forms.Item(m).elements; for i := 0 to ovElements.Length - 1 do begin try if (CompareText(ovElements.item(i).id, 'MsgCc') = 0) and (CompareText(ovElements.item(i).type, 'text') = 0) then begin ovElements.item(i).value := 'adresse@server.tl'; end; except end; end; end; end; end; end; end; end;
end. |
Und damit es nachvollzogen werden kann hier der HTML-Quelltext:
(Ist leider bissl unübersichtlich, aber ich habe die betreffende zeile mal hervorgehoben)
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: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263:
| <!--Copyright (c) 2000-2003 Microsoft Corporation. All rights reserved.--> <!--CURRENT FILE== "IE5" "WIN32" composenote --> <!--CURRENT TEMPLATE == IPF.Note.05000001 --> <HTML xmlns:IE DIR=LTR> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> <?XML:NAMESPACE PREFIX="WM"/> <SCRIPT src="http://****/****/****/?cmd=script&template=loc_note&cache=1&ver=6.5.7232.34"></SCRIPT> <SCRIPT src="http://****/****/****/?cmd=script&template=loc_keystrokes&cache=1&ver=6.5.7232.34"></SCRIPT> <SCRIPT language="javascript"> var g_sSigHtml = "<DIV><FONT face=Arial color=#000000 size=2>\r\n<DIV class=MsoNormal style=\"MARGIN: 0in 0in 0pt; mso-pagination: none; mso-layout-grid-align: none\"><SPAN style=\"FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial\">Mit freundlichen Grüssen<\/SPAN><SPAN style=\"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial\"><?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" \/><o:p><\/o:p><\/SPAN><\/DIV>\r\n<DIV class=MsoNormal style=\"MARGIN: 0in 0in 0pt; mso-pagination: none; mso-layout-grid-align: none\"><SPAN style=\"FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial\">Denis Klisch & Michael Weißberg<BR>Hotline-Service TV<BR><BR>LMR Service and Consulting GmbH<BR>Preuschwitzer Str. 20<BR>02625 Bautzen<BR>Tel.: +49(0) 3591 \/ 380 - 1142 oder - 1143<BR>Fax.: +49(0) 3591 \/ 380 1115<BR><\/SPAN><SPAN style=\"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial\"><A href=\"mailto:hotline@letmerepair.com\">hotline@letmerepair.com<\/A><BR><\/SPAN><SPAN style=\"FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial\"><A href=\"http:\/\/www.letmerepair.com\">www.letmerepair.com<\/A><\/SPAN><\/DIV><\/FONT><\/DIV>"; var g_sSigText = "Mit freundlichen Grüssen\r\nDenis Klisch & Michael Weißberg\r\nHotline-Service TV\r\n\r\nLMR Service and Consulting GmbH\r\nPreuschwitzer Str. 20\r\n02625 Bautzen\r\nTel.: +49(0) 3591 \/ 380 - 1142 oder - 1143\r\nFax.: +49(0) 3591 \/ 380 1115\r\nhotline@letmerepair.com\r\nwww.letmerepair.com"; var g_bAutoSignatureOn = true; var g_sContacts = "Kontakte"; var g_sBase = "http://****/****/****"; var g_sUserDisp = "Hotline"; var g_sFontTag = "<FONT face='Arial' color=#000000 size=2> </FONT>"; var g_PrintRecurrencePattern = "Das Serienmuster kann nicht ermittelt werden."; var g_iInstanceType = ""; var g_szFolder = "Entw%C3%BCrfe"; var g_szVirtualRoot="http://****/****"; var g_szHtmlViewUrl=""; var g_szResLang = "GER"; var g_fAllowAttachments = true; var g_fSpellOnSend = false; var g_fCanSpellOnSend = true; var g_bEnableSignature = true; var g_iDefaultAddrSearch = 1; var g_fIsReportReceiptFwd = "0"; var g_thid = 0; </SCRIPT> <LINK rel="stylesheet" type="text/css" href="/****/6.5.7232.34/controls/owastyle.css"> <LINK rel="stylesheet" type="text/css" href="http://****/****/themes/0/owacolors.css"> <LINK rel="stylesheet" type="text/css" href="/****/6.5.7232.34/controls/style30.css"> <SCRIPT src="/****/6.5.7232.34/controls/util_owa.js"></SCRIPT> <SCRIPT src="/****/6.5.7232.34/controls/util_forms.js"></SCRIPT> <SCRIPT src="/****/6.5.7232.34/controls/frm_composenote.js"></SCRIPT> <SCRIPT src="/****/6.5.7232.34/controls/util_buttons.js"></SCRIPT> <SCRIPT language='javascript'> var g_fIsDelegate = "0"; var g_szAcceptLang = "de"; var g_fAddToContacts = true; var g_fPublic = false; var g_bCompose = true; var g_szOpt1 = "An"; var g_szOpt2 = "Cc"; var g_szOpt3 = "Bcc"; </SCRIPT> <SCRIPT language="javascript" src="/****/6.5.7232.34/controls/util_recipients.js"></SCRIPT> <SCRIPT language='javascript' For="tbContentElement" Event="DocumentComplete"> tbContentElement_DocumentComplete(); </SCRIPT> <SCRIPT language="javascript" for="tbContentElement" event="onclick"> hideRecipCtxMnu(); </SCRIPT> <TITLE> Unbenannt -- Nachricht </TITLE> <SCRIPT for="btnRecip" event="onclick()" language="javascript"> event.cancelBubble = true; event.returnValue = false; hideRecipCtxMnu(); if (g_fIsDelegate != "1") { openGal( "An","Cc","Bcc", objMessage); } return false; </SCRIPT> <STYLE> WM\:MESSAGE {behavior:url("/****/6.5.7232.34/controls/ctrl_message.htc");}; @media all { IE\:clientCaps {behavior:url(#default#clientcaps)} } .tbDivider{border-right:1px solid;} </STYLE> <BASE href="http://****/****/****/" /> <SCRIPT FOR="cbButton" EVENT="onmousedown()" LANGUAGE="JavaScript" > return onCbMouseDown(this); </SCRIPT> <SCRIPT FOR="cbButton" EVENT="onclick()" LANGUAGE="JavaScript" > return onCbClickEvent(this); </SCRIPT> <SCRIPT FOR="cbButton" EVENT="oncontextmenu()" LANGUAGE="JavaScript" > return(event.ctrlKey); </SCRIPT> </HEAD> <XML id="idXmlMessageData"> <messagedata xmlns:a="DAV:" xmlns:b="urn:schemas:mailheader:" xmlns:c="urn:schemas:httpmail:" xmlns:g="http://schemas.microsoft.com/exchange/" xmlns:k="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" > <a:contentclass></a:contentclass> <c:importance k:dt="int" dirty="0"></c:importance> <g:sensitivity-long k:dt="int" dirty="1"></g:sensitivity-long> <c:subject dirty="1"></c:subject> <g:readreceiptrequested k:dt="int" dirty="0"></g:readreceiptrequested> <g:deliveryreportrequested k:dt="int" dirty="0"></g:deliveryreportrequested> <c:htmldescription dirty="0"></c:htmldescription> </messagedata> </XML> <BODY class="noteBody"> <IE:clientCaps id="oClientCaps" /> <WM:MESSAGE id="objMessage" onupdaterecipients="objMessage_UpdateRecipients();" onlogintimeout = "LoginTimeout();" messageXML="idXmlMessageData" onsave="onSaveEx();" onsend="objMessage_OnSend();" onchecknames="objMessage_OnCheckNames();" onupdateattachments="onUpdateAttachTable();" onerror="onMsg_Error();" url="http://****/****/****" draftsURL="http://****/****/****/Entw%C3%BCrfe" baseURL = "http://****/****/****" msgID="" acceptLang="de" > </WM:MESSAGE> <DIV id="mnuRecips" class="divContextMenu" style="display:none;"></DIV> <TABLE id="idToolbar" class="cbToolbar" cellpadding="0" cellspacing="0" nowrap><TR> <TD class="tbDivider" nowrap><A class="tbButton" name="cbButton" id="send" href="#" title="Senden"><IMG align=absmiddle src="http://****/****/img/send.gif">Senden</A></TD> <TD id=tbSave nowrap><A class="tbButton" name="cbButton" id='Save' href="#" title="Speichern"><IMG align=absmiddle src="http://****/****/img/save.gif"></A></TD> <TD class="tbDivider" nowrap><A class="tbButton" name="cbButton" id="print" href="#" title="Drucken" unselectable="on"><IMG align=absmiddle src="http://****/****/img/print.gif" unselectable="on"></A></TD> <TD nowrap><A class="tbButton" name="cbButton" id='InsertSignature' href="#" title="Signatur einfügen" unselectable="on"><IMG align=absmiddle src="http://****/****/img/sig.gif" unselectable="on"></A></TD> <TD nowrap><A class="tbButton" name="cbButton" id='SpellCheck' href="#" title="Rechtschreibung" unselectable="on"><IMG align=absmiddle src="http://****/****/img/spelling.gif" unselectable="on"></A></TD> <TD nowrap class="tbDivider"><A class="tbButton" name="cbButton" id='ToolBarAttach' href="#" title="Anlage hinzufügen"><IMG align=absmiddle src="http://****/****/img/attach.gif"></A></TD> <TD class="tbDivider" nowrap><A class="tbButton" name="cbButton" id="chknames" href="#" title="Namen überprüfen" unselectable="on"><IMG align=absmiddle src="http://****/****/img/checkname.gif" unselectable="on"></A></TD> <TD> <A id="IMPHIGH" name="cbButton" class="tbButton" sticky stickytoggle="IMPLOW" href="#" title="Wichtigkeit: hoch"> <IMG align="absmiddle" src="http://****/****/img/prio-high.gif"></A> </TD> <TD class="tbDivider"> <A id="IMPLOW" name="cbButton" class="tbButton" sticky stickytoggle="IMPHIGH" href="#" title="Wichtigkeit: niedrig"> <IMG align="absmiddle" src="http://****/****/img/prio-low.gif"></A> </TD> <TD class="tbDivider" nowrap> <A id="options" name="cbButton" class="tbButton" href="#" title="Optionen"> <IMG align="absmiddle" src="http://****/****/img/options.gif">Optionen...</A> </TD> <TD class="tbHelp"> <A id="help" class="tbButton" onclick="return onCbClickEvent(this)" href="#" title="Hilfe"><NOBR> <IMG align=absmiddle class="imgHlp" src="http://****/****/img/help.gif" border="0" width="16" height="16">Hilfe</NOBR><BR> <SPAN id="idHelpLinkText" style='display:none;'> http://****/****/help/GER/ie5/default.htm?composenote.htm </SPAN> </A> </TD> <TD><DIV id="idFontSize" style="visiblity:hidden"> </DIV></TD> </TR></TABLE> <TABLE cellpadding="5" width="100%"> <TR> <TD> <DIV id="curUser" class="prntOnly curUser"></DIV> <TABLE id="tblHeader" class="msgHeader msgHdr_Note" cols="2"> <COLGROUP><COL class="msgHdrCN1"><COL class="msgHdrCN2"></COLGROUP> <TR id="to_RecipientRow"> <TD valign="top"> <BUTTON id="recipTo" name="btnRecip" class="btnRecip" tabindex="-1"><U>A</U>n...</BUTTON> </TD> <TD id="cellTo"> <DIV class="recipBox" style="width:100%;"> <DIV id="divTo" name="fldText" class="fldTextRecip recipWell" onclick="event_onrecipclick(1)" ondblclick="event_onrecipdblclick(1)" onkeydown="event_onrecipkeydown(1)" oncontextmenu="event_onrecipcontextmenu(1)"> </DIV> <INPUT type="text" id="MsgTo" class="fldInput recipInput" style="width:100%;" value=""> </DIV> </TD> </TR> <TR id="cc_RecipientRow"> <TD valign="top"> <BUTTON id="recipCc" name="btnRecip" class="btnRecip" tabindex="-1"><U>C</U>c...</BUTTON> </TD> <TD id="cellCc"> <DIV class="recipBox" style="width:100%;"> <DIV id="divCc" name="fldText" class="fldTextRecip recipWell" onclick="event_onrecipclick(2)" ondblclick="event_onrecipdblclick(2)" onkeydown="event_onrecipkeydown(2)" oncontextmenu="event_onrecipcontextmenu(2)"> </DIV> <INPUT type="text" id="MsgCc" class="fldInput recipInput" style="width:100px;" value=""> </DIV> </TD> </TR> <TR id="bcc_RecipientRow"> <TD valign="top"> <BUTTON id="recipBcc" name="btnRecip" class="btnRecip" tabindex="-1"><U>B</U>cc...</BUTTON> </TD> <TD id="cellBcc"> <DIV class="recipBox" style="width:100%;"> <DIV id="divBcc" name="fldText" class="fldTextRecip recipWell" onclick="event_onrecipclick(3)" ondblclick="event_onrecipdblclick(3)" onkeydown="event_onrecipkeydown(3)" oncontextmenu="event_onrecipcontextmenu(3)"> </DIV> <INPUT type="text" id="MsgBcc" class="fldInput recipInput" style="width:100%;" value=""> </DIV> </TD> </TR> <TR id="subject_RecipientRow"> <TD class="fldLabel" style="vertical-align:middle" align="center" nowrap><SPAN id="subjectLabel" >Betreff: </SPAN></TD> <TD> <INPUT type="text" id="subject" style="width:100%;" dirty="1" onchange="this.dirty='1'"; class="fldInput ipFlat" MAXLENGTH="255" value=""> </TD> </TR> <TR id="trGroove" style="display:none"><TD class="noPrint" colspan="2"><HR></TD></TR> <TR id="trWhen" style="display:none"> <TD class="fldLabel" style="vertical-align:middle;" align="center" nowrap>Zeit: </TD> <TD> <SPAN id="spanWhenText" name="fldText"> <NOBR> - </NOBR> </SPAN> </TD> </TR> <TR id="trLocation" style="display:none"> <TD class="fldLabel" style="vertical-align:middle;" align="center" nowrap>Ort: </TD> <TD> <SPAN name="fldText"> <NOBR></NOBR> </SPAN> </TD> </TR> <TR> <TD class="fldLabel" id="_tdAttachLabel" nowrap> <BUTTON id="Attach" class=btnAttach onclick="onCbClick(this.id, true);">Anlagen:</BUTTON></TD> <TD id="_tdAttachWell"> <DIV id="idAttachmentWell" class="AttachmentWell"> </DIV> </TD> </TR> </TABLE> <DIV id="idFormatbar" class="FORMATBAR trButtons" nowrap onbehaviorready="initFormatbarStyleList(0x2)" dhtmlEdit="tbContentElement" imagePath="http://****/****/img" fonts="Arial:Arial;Courier New:Courier New;System:System;Times New Roman:Times New Roman;Verdana:Verdana" tooltips="Paragraph Styles;Dialogfeld 'Schrift';Font Names;Font Size;Schriftfarbe;Fett;Kursiv;Unterstrichen;Linksbündig;Zentriert;Rechtsbündig;Aufzählungszeichen;Nummerierung;Einzug verkleinern;Einzug vergrößern;Von links nach rechts;Von rechts nach links" formatLabels="F;K;U" buttonHTML="FontDialog::<IMG style='cursor:hand;' src='http://****/****/img/tool-font.gif'>" contextMenuStrings="Rückgängig;Ausschneiden;Kopieren;Einfügen;Löschen;Alles markieren" fontName="Arial" fontSize="2" fontColor="#000000" fontBold="0" fontItalic="0" fontUnderline="0" > </DIV> <DIV id="prnMsgBody" class="MSGBODY" style="display:none"></DIV> <OBJECT class="MSGBODY" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" ID="tbContentElement" VIEWASTEXT> <PARAM name="ActivateApplets" value="0"> <PARAM name="ActivateActiveXControls" value="-1"> <PARAM name="ActivateDTCs" value="-1"> <PARAM name="ShowDetails" value="0"> <PARAM name="ShowBorders" value="0"> <PARAM name="Appearance" value="0"> <PARAM name="Scrollbars" value="-1"> <PARAM name="ScrollbarAppearance" value="1"> <PARAM name="SourceCodePreservation" value="-1"> <PARAM name="AbsoluteDropMode" value="0"> <PARAM name="SnapToGrid" value="0"> <PARAM name="SnapToGridX" value="50"> <PARAM name="SnapToGridY" value="50"> <PARAM name="UseDivOnCarriageReturn" value="1"> </OBJECT> <TEXTAREA id="idBody" style="display:none;"></TEXTAREA> </TD> </TR> </TABLE> </BODY> </HTML> |
Ich hoffe Ihr könnt mir bei diesem (für mich) etwas kniffligem Problem weiterhelfen.
Danke schoneinmal im Vorraus
Gruß Micha