multipart message in PHP to send mail via lotus notes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madmak
    New Member
    • May 2007
    • 2

    #1

    multipart message in PHP to send mail via lotus notes

    Hi, I am a noob with PHP and need some asistance regarding PHP and lotus notes. I am trying to create a multipart message in PHP to send mail via lotus notes.

    Here is the code snippet.

    [CODE=php]<?php
    ---some code here --

    $session_notes = new COM("Lotus.Note sSession");

    $session_notes->Initialize("<p assword>");
    print "Current user: ".$session_note s->CommonUserNa me . "\n\n";

    $db = $session_notes->getDatabase( "", "Test.nsf" ) or die("Couldn't get database");
    $session_notes -> ConvertMime = FALSE;

    $my_stream = $session_notes -> CreateStream();

    $email_object = $db -> CreateDocument( );

    $email_object ->ReplaceItemVal ue("Form","Memo ");

    $body = $email_object -> CreateMIMEEntit y();

    $bodyHeader = $body -> CreateHeader("C ontent-Type");

    $bodyHeader -> SetHeaderVal("m ultipart/mixed");

    $bodyHeader = $body -> CreateHeader("S ubject");

    $bodyHeader -> SetHeaderVal("M IME Message");

    $bodyHeader = $body -> CreateHeader("T o");

    $bodyHeader -> SetHeaderVal("m admak@foo.com") ;

    // problem with this line
    $child = $body -> createChildEnti ty();

    $my_stream -> WriteText("<htm l>This is the first child</html>");

    $child -> SetContentFromT ext($my_stream, "text/plain", ENC_NONE);

    $my_stream -> truncate();

    $child = $body -> createChildEnti ty();

    $my_stream -> WriteText("<htm l>This is the second child</html>");

    $child -> SetContentFromT ext($my_stream, "text/plain", ENC_NONE);

    $email_object -> Send(False);

    $session_notes -> ConvertMime = TRUE;

    ?> [/CODE]

    I get the following error when I run this code.
    Code:
     
    Fatal error: Uncaught exception 'com_exception' with message 'Parameter -1: Type 
    mismatch. 
    ' in C:\Mailing\testmail.php:33 
    Stack trace: 
    #0 C:\Mailing\testmail.php(33): variant->createChildEntity() 
    #1 {main} 
    thrown in C:\Mailing\testmail.php on line 33
    Can somebody help me out with this.

    Also, the other question that I have is what is the difference between creating an object of type "Lotus.NotesSes sion" and "Notes.NotesSes sion".

    Thanks in advance..
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya madmak. Welcome to TSDN!

    Originally posted by madmak
    I get the following error when I run this code.
    Code:
     
    Fatal error: Uncaught exception 'com_exception' with message 'Parameter -1: Type 
    mismatch. 
    ' in C:\Mailing\testmail.php:33 
    Stack trace: 
    #0 C:\Mailing\testmail.php(33): variant->createChildEntity() 
    #1 {main} 
    thrown in C:\Mailing\testmail.php on line 33
    Is C:\Mailing\test mail.php one of your scripts? What are you trying to do on or around line 33 that's throwing the exception?

    Comment

    • madmak
      New Member
      • May 2007
      • 2

      #3
      Hi All

      testmail.php is the script for which the code is posted.
      In line 33 ($child = $body -> createChildEnti ty();) I am trying to create a mime child entity which will hold the attachment in the mail message.

      Comment

      Working...