Seite 1 von 1

PureDisphelper + Outlook

Verfasst: 26.10.2007 19:45
von marco2007
Hi, liebe Kollegen!

Kann mir bitte jemand folgenden Code PB-Fähig machen? Ich blicke leider bei PureDisphelper noch gar nicht durch.

Code: Alles auswählen

/* **************************************************************************
 * EmailOutlook:
 *   Demonstrates sending an email using Outlook in plain C.
 *
 ============================================================================ */
void EmailOutlook(LPCTSTR szTo, LPCTSTR szSubject, LPCTSTR szBody)
{
	DISPATCH_OBJ(olApp);
	DISPATCH_OBJ(olMsg);

	/* Create Outlook object and create a new mail item */
	dhCreateObject(L"Outlook.Application", NULL, &olApp);
	dhGetValue(L"%o", &olMsg, olApp, L".CreateItem(%d)", 0);

	dhPutValue(olMsg, L".Subject = %T", szSubject);
	dhPutValue(olMsg, L".To = %T",      szTo);
	dhPutValue(olMsg, L".Body = %T",    szBody);

	/* To add an attachment:
	 * dhCallMethod(olMsg, L".Attachments.Add(%s)", "FilePath.ext");
	 */

	/* Display and attempt to send email */
	dhCallMethod(olMsg, L".Display");
	dhCallMethod(olMsg, L".Send");
	
	SAFE_RELEASE(olMsg);
	SAFE_RELEASE(olApp);
}
Der Topf wird bei Erfolg natürlich um einen Euro erhöht!

Danke
Marco

Verfasst: 28.10.2007 14:00
von dysti
Hier hast du mal ein Beispiel, was Kiffi erstellt hat, ist zwar für Exel, aber an dem Beispiel kannst du sehen, wie die Befehle verwendet werden:

Code: Alles auswählen

; example by Kiffi

;EnableExplicit

Define.l ExcelApp, Workbook

dhToggleExceptions(#True)
datum.s = "31.12.2006"
ExcelApp = dhCreateObject("Excel.Application")

If ExcelApp
  
  dhPutValue(ExcelApp, ".Visible = %b", #True)




  dhGetValue("%o", @Workbook, ExcelApp, ".Workbooks.Add")

  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 1, @"Feel")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 2, 1, @"the")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 3, 1, @"pure")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 4, 1, @"Power")

  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 2, @"the")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 3, @"pure")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 4, @"Power")
   
   dhPutValue(ExcelApp, "Cells(%d, %d).Value = %T", 5, 3, @datum)

  dhGetValue("%T", @ReturnValue, ExcelApp, "Cells(%d, %d).Value",5, 3)
  strValue.s=PeekS(ReturnValue )
  
  MessageRequester("PureDispHelper-ExcelDemo",strValue)

  dhCallMethod(ExcelApp, ".Quit")
  
  dhReleaseObject(Workbook) : Workbook = 0
  dhReleaseObject(ExcelApp) : ExcelApp = 0

Else

  MessageRequester("PureDispHelper-ExcelDemo", "Couldn't create Excel-Object")

EndIf
Könnte so aussehen:

Code: Alles auswählen

; example by Kiffi

;EnableExplicit

Define.l olApp, olMsg

dhToggleExceptions(#True)
datum.s = "31.12.2006"
olApp = dhCreateObject("Outlook.Application")

If olApp
  
  dhPutValue(olApp, ".Visible = %b", #True)

  dhGetValue("%o", @olMsg, olApp, .CreateItem(%d)")

  dhPutValue(olApp, ".Subject = %T", szSubject)
  dhPutValue(olApp, ".To = %T",      szTo)
  dhPutValue(olApp, ".Body = %T",    szBody)
  
  
  /* To add an attachment:
    * dhCallMethod(olMsg, ".Attachments.Add(%s)", "FilePath.ext")
    */

   /* Display And attempt To send email */
   dhCallMethod(olMsg, ".Display")
   dhCallMethod(olMsg, ".Send")
   dhCallMethod(olApp, ".Quit")
  
  dhReleaseObject(olMsg) : olMsg = 0
  dhReleaseObject(olApp) : olApp = 0

Else

  MessageRequester("PureDispHelper-OutlookDemo", "Couldn't create Outlook-Object")

EndIf

Verfasst: 28.10.2007 16:06
von marco2007
So funkt es:

Code: Alles auswählen

Define.l olApp, olMsg 

dhToggleExceptions(#True) 
olApp = dhCreateObject("Outlook.Application") 

If olApp 
 
  dhGetValue("%o", @olMsg, olApp, ".CreateItem(%d)", 0) 

  dhPutValue(olMsg, ".Subject = %T", @"Betreff")         ;OlMsg!!
  dhPutValue(olMsg, ".To = %T", @"Mail@mail.com") 
  dhPutValue(olMsg, ".Body = %T", @"Hier ist der Text") 
  
  
   dhCallMethod(olMsg, ".Attachments.Add(%s)", @"e:\IETool.zip") 
   dhCallMethod(olMsg, ".Display") 
   ;dhCallMethod(olMsg, ".Send") 
   ;dhCallMethod(olApp, ".Quit") 
  
  dhReleaseObject(olMsg) : olMsg = 0 
  dhReleaseObject(olApp) : olApp = 0 

Else 

  MessageRequester("PureDispHelper-OutlookDemo", "Couldn't create Outlook-Object") 

EndIf 

Verfasst: 28.10.2007 18:49
von dysti
Prima, Hauptsache man kommt auf den richtigen Weg.