By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

multipart message in PHP to send mail via lotus notes

P: 2
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.

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. ---some code here -- 
  3.  
  4. $session_notes = new COM("Lotus.NotesSession"); 
  5.  
  6. $session_notes->Initialize("<password>"); 
  7. print "Current user: ".$session_notes->CommonUserName . "\n\n"; 
  8.  
  9. $db = $session_notes->getDatabase( "", "Test.nsf" ) or die("Couldn't get database"); 
  10. $session_notes -> ConvertMime = FALSE; 
  11.  
  12. $my_stream = $session_notes -> CreateStream(); 
  13.  
  14. $email_object = $db -> CreateDocument(); 
  15.  
  16. $email_object ->ReplaceItemValue("Form","Memo"); 
  17.  
  18. $body = $email_object -> CreateMIMEEntity(); 
  19.  
  20. $bodyHeader = $body -> CreateHeader("Content-Type"); 
  21.  
  22. $bodyHeader -> SetHeaderVal("multipart/mixed"); 
  23.  
  24. $bodyHeader = $body -> CreateHeader("Subject"); 
  25.  
  26. $bodyHeader -> SetHeaderVal("MIME Message"); 
  27.  
  28. $bodyHeader = $body -> CreateHeader("To"); 
  29.  
  30. $bodyHeader -> SetHeaderVal("madmak@foo.com"); 
  31.  
  32. // problem with this line
  33. $child = $body -> createChildEntity();
  34.  
  35. $my_stream -> WriteText("<html>This is the first child</html>"); 
  36.  
  37. $child -> SetContentFromText($my_stream, "text/plain", ENC_NONE); 
  38.  
  39. $my_stream -> truncate(); 
  40.  
  41. $child = $body -> createChildEntity(); 
  42.  
  43. $my_stream -> WriteText("<html>This is the second child</html>"); 
  44.  
  45. $child -> SetContentFromText($my_stream, "text/plain", ENC_NONE); 
  46.  
  47. $email_object -> Send(False); 
  48.  
  49. $session_notes -> ConvertMime = TRUE; 
  50.  
  51. ?> 
I get the following error when I run this code.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Fatal error: Uncaught exception 'com_exception' with message 'Parameter -1: Type 
  3. mismatch. 
  4. ' in C:\Mailing\testmail.php:33 
  5. Stack trace: 
  6. #0 C:\Mailing\testmail.php(33): variant->createChildEntity() 
  7. #1 {main} 
  8. thrown in C:\Mailing\testmail.php on line 33 
  9.  
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.NotesSession" and "Notes.NotesSession".

Thanks in advance..
May 14 '07 #1
Share this Question
Share on Google+
2 Replies


pbmods
Expert 5K+
P: 5,821
Heya madmak. Welcome to TSDN!

I get the following error when I run this code.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Fatal error: Uncaught exception 'com_exception' with message 'Parameter -1: Type 
  3. mismatch. 
  4. ' in C:\Mailing\testmail.php:33 
  5. Stack trace: 
  6. #0 C:\Mailing\testmail.php(33): variant->createChildEntity() 
  7. #1 {main} 
  8. thrown in C:\Mailing\testmail.php on line 33 
  9.  
Is C:\Mailing\testmail.php one of your scripts? What are you trying to do on or around line 33 that's throwing the exception?
May 15 '07 #2

P: 2
Hi All

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

Post your reply

Sign in to post your reply or Sign up for a free account.