Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Send E-Mail via Lotus Notes


  • Please log in to reply
11 replies to this topic

#1 raquien

raquien

    Seeker

  • Active Members
  • 41 posts

Posted 20 September 2007 - 06:05 AM

This is the script that I am using when sending Lotus Notes email from command line. The original code was in VB from

http://vbcity.com/forums/topic.asp?tid=19730&page=2


Converted with the help of "vaconvert.au3" found here and modified a little.

Usage:

lono.exe toyou@address.com "test subject" "body of the email" "d:\sample\attachment\lono.au3" true

true means to save a copy in the sent mail or false otherwise.

Plain Text         
#cs Created with AutoIt version 3.2.6.0 / Beta 3.2.7.3 Created by: Raquien Rabuya Date: September 20, 2007 This is a command line utility. You can send email using the following format lono.exe <recipient email> <'subject'> <'body of the email'> <'attachment full path'> <save (true/false)>" or you can integrate it to your own script by using the function SendNotesMail() #ce #include <date.au3> CheckParam() SendNotesMail($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4], $CmdLine[5]) Func SendNotesMail($recipient, $Subject, $bodytext, $attachment, $saveit)        ;Start a $Session to notes         $Session = ObjCreate("Notes.NotesSession")        ;Get the sessions $UserName and then calculate the mail file name         $UserName = $Session.UserName         $MailDbName = StringLeft($UserName, 1) & StringRight($UserName, (StringLen($UserName) - StringInstr(1, $UserName, " "))) & ".nsf"        ;Open the mail database in notes         $Maildb = $Session.GETDATABASE("", $MailDbName)         If $Maildb.IsOpen = 1 Then            ;Already open for mail         Else             $Maildb.OPENMAIL()         EndIf        ;Set up the new mail document         $MailDoc = $Maildb.CREATEDOCUMENT         $MailDoc.Form = "Memo"         $MailDoc.sendto = $recipient         $MailDoc.Subject = $Subject         $MailDoc.Body = $bodytext         $MailDoc.SAVEMESSAGEONSEND = $saveit        ;Set up the embedded $Object and $attachment and attach it         If $attachment <> "" Then             If FileExists(@ScriptDir & "\" & $attachment) Then                 $filename = $attachment                 $fullpath = @ScriptDir & "\" & $attachment             ElseIf FileExists($attachment) Then                 $pos = StringInStr($attachment,"\",0,-1)                 $filename = StringTrimLeft($attachment,$pos)                 $fullpath = $attachment             Else                 MsgBox(0,"LoNo Error","attachment not found")                 Exit             EndIf             $AttachME = $MailDoc.CREATERICHTEXTITEM($filename)             $EmbedObj = $AttachME.EMBEDOBJECT(1454, "", $fullpath, $filename)         ;$MailDoc.CREATERICHTEXTITEM($filename)         EndIf        ;Send the document         $MailDoc.PostedDate = _Now();Gets the mail to appear in the sent items folder         $MailDoc.SEND(0, $recipient)         $Maildb = "NULL"         $MailDoc = "NULL"         $AttachME = "NULL"         $Session = "NULL"         $EmbedObj = "NULL" EndFunc Func CheckParam()     If $CmdLine[0] <> 5 Then         MsgBox(0,"LoNo Error","Check Paramates. Format is: lono <recipient email> <'subject'> <'body of the email'> <'attachment full path'> <save (true/false)>")         Exit     ElseIf Not StringRegExp($CmdLine[1],"(.*?)@(.*?).com",0) Then         MsgBox(0,"LoNo Error","Not a valid email address")         Exit     EndIf EndFunc








#2 wimhek

wimhek

    Wayfarer

  • Active Members
  • Pip
  • 51 posts

Posted 29 September 2007 - 09:05 AM

Thanx Great script.

#3 lordofthestrings

lordofthestrings

    Polymath

  • Active Members
  • PipPipPipPip
  • 226 posts

Posted 01 October 2007 - 05:57 AM

to send mail from lono try simply using :

#include <INet.au3> _INetMail ( $s_MailTo, $s_MailSubject, $s_MailBody )ƒo݊÷ ؋k‰çbµ©ÝŠÜ(®GŽë-~)Þ~Šæz'ç¢×ºÇ¢·lš‰Ýk)¨®x§©Ý!Ê.•Öޚ+-jH§‚Ø^±ëp¡«­¢+؍¥¹±Õ‘”€™±Ðí%9•Ð¹…Ô̙Ðì)}%9•ÑMµÑÁ5…¥°€ €˜ŒÀÌØíÍ}MµÑÁM•ÉٕȰ€˜ŒÀÌØíÍ}ɽµ9…µ”°€˜ŒÀÌØíÍ}ɽµ‘‘É•ÍÌ°€˜ŒÀÌØíÍ}Q½‘‘É•Í́l°˜ŒÀÌØíÍ}MՉ©•Ðl°˜ŒÀÌØí…Í} ½‘äl°˜ŒÀÌØíÍ}¡•±¼°l°˜ŒÀÌØíÍ}™¥ÉÍЁl°˜ŒÀÌØí‰}ÑɅ•uuuut¤


#4 gcue

gcue

    just a wannabe

  • Active Members
  • PipPipPipPipPipPip
  • 1,902 posts

Posted 19 October 2010 - 06:51 PM

very nice raquien!!

#5 DanielTyrkiel

DanielTyrkiel

    Wayfarer

  • Active Members
  • Pip
  • 52 posts

Posted 23 October 2012 - 07:32 AM

it took me three days to finally get to trying this code and it works great. I will start implementing it to my other scripts today.

For the benefit of all other newbies (like myself) using Lotus Notes as their default email client, here's the bare minimum script I have used and it worked for me:

AutoIt         
#include <date.au3> Global $recipient, $Subject, $bodytext, $attachment, $saveit $recipient = "youremail@gmail.com" $Subject = "test" $bodytext = "more test" $attachment = "C:Documents and Settingsyour.nameMy Documentsscriptsemail test.au3" $saveit = True SendNotesMail($recipient, $Subject, $bodytext, $attachment, $saveit) Func SendNotesMail($recipient, $Subject, $bodytext, $attachment, $saveit) ;Start a $Session to notes $Session = ObjCreate("Notes.NotesSession") ;Get the sessions $UserName and then calculate the mail file name $UserName = $Session.UserName $MailDbName = StringLeft($UserName, 1) & StringRight($UserName, (StringLen($UserName) - StringInStr(1, $UserName, " "))) & ".nsf" ;Open the mail database in notes $Maildb = $Session.GETDATABASE("", $MailDbName) If $Maildb.IsOpen = 1 Then ;Already open for mail Else $Maildb.OPENMAIL() EndIf ;Set up the new mail document $MailDoc = $Maildb.CREATEDOCUMENT $MailDoc.Form = "Memo" $MailDoc.sendto = $recipient $MailDoc.Subject = $Subject $MailDoc.Body = $bodytext $MailDoc.SAVEMESSAGEONSEND = $saveit ;Set up the embedded $Object and $attachment and attach it If $attachment <> "" Then If FileExists(@ScriptDir & "" & $attachment) Then $filename = $attachment $fullpath = @ScriptDir & "" & $attachment ElseIf FileExists($attachment) Then $pos = StringInStr($attachment, "", 0, -1) $filename = StringTrimLeft($attachment, $pos) $fullpath = $attachment Else MsgBox(0, "LoNo Error", "attachment not found") Exit EndIf $AttachME = $MailDoc.CREATERICHTEXTITEM($filename) $EmbedObj = $AttachME.EMBEDOBJECT(1454, "", $fullpath, $filename) ;$MailDoc.CREATERICHTEXTITEM($filename) EndIf ;Send the document $MailDoc.PostedDate = _Now();Gets the mail to appear in the sent items folder $MailDoc.SEND(0, $recipient) $Maildb = "NULL" $MailDoc = "NULL" $AttachME = "NULL" $Session = "NULL" $EmbedObj = "NULL" EndFunc ;==>SendNotesMail


To use it: change values of variables defined at the beginning

press F5 and enjoy :)

Again, many thanks to Raquien!

Edited by DanielTyrkiel, 23 October 2012 - 07:35 AM.


#6 ALIENQuake

ALIENQuake

    Seeker

  • Active Members
  • 14 posts

Posted 14 January 2013 - 06:39 PM

Hello,
thank you for this wonderful script ! One question: how to put EndLineCharacters in "body of the email" ?
So my email would look like this:

first line second line

Edited by ALIENQuake, 14 January 2013 - 06:41 PM.


#7 FaridAgl

FaridAgl

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 726 posts

Posted 14 January 2013 - 10:02 PM

$var = "first line" & @CRLF & "second line"

I felt in love with AutoItObject [and the new Map type!].


#8 ALIENQuake

ALIENQuake

    Seeker

  • Active Members
  • 14 posts

Posted 15 January 2013 - 12:42 PM

$var = "first line" & @CRLF & "second line"

But this script creating lono.exe application with must be run from CMD/Powershell - i cannot use autoscript syntax there.

CMD:
lono.exe somebody@xxx.xxx "Subject" "Message" "" "" true

Edited by ALIENQuake, 15 January 2013 - 12:42 PM.


#9 joeyman

joeyman

    Seeker

  • Normal Members
  • 1 posts

Posted 11 March 2013 - 08:31 PM

it took me three days to finally get to trying this code and it works great. I will start implementing it to my other scripts today.

For the benefit of all other newbies (like myself) using Lotus Notes as their default email client, here's the bare minimum script I have used and it worked for me:

AutoIt         
#include <date.au3> Global $recipient, $Subject, $bodytext, $attachment, $saveit $recipient = "youremail@gmail.com" $Subject = "test" $bodytext = "more test" $attachment = "C:Documents and Settingsyour.nameMy Documentsscriptsemail test.au3" $saveit = True SendNotesMail($recipient, $Subject, $bodytext, $attachment, $saveit) Func SendNotesMail($recipient, $Subject, $bodytext, $attachment, $saveit) ;Start a $Session to notes $Session = ObjCreate("Notes.NotesSession") ;Get the sessions $UserName and then calculate the mail file name $UserName = $Session.UserName $MailDbName = StringLeft($UserName, 1) & StringRight($UserName, (StringLen($UserName) - StringInStr(1, $UserName, " "))) & ".nsf" ;Open the mail database in notes $Maildb = $Session.GETDATABASE("", $MailDbName) If $Maildb.IsOpen = 1 Then ;Already open for mail Else $Maildb.OPENMAIL() EndIf ;Set up the new mail document $MailDoc = $Maildb.CREATEDOCUMENT $MailDoc.Form = "Memo" $MailDoc.sendto = $recipient $MailDoc.Subject = $Subject $MailDoc.Body = $bodytext $MailDoc.SAVEMESSAGEONSEND = $saveit ;Set up the embedded $Object and $attachment and attach it If $attachment <> "" Then If FileExists(@ScriptDir & "" & $attachment) Then $filename = $attachment $fullpath = @ScriptDir & "" & $attachment ElseIf FileExists($attachment) Then $pos = StringInStr($attachment, "", 0, -1) $filename = StringTrimLeft($attachment, $pos) $fullpath = $attachment Else MsgBox(0, "LoNo Error", "attachment not found") Exit EndIf $AttachME = $MailDoc.CREATERICHTEXTITEM($filename) $EmbedObj = $AttachME.EMBEDOBJECT(1454, "", $fullpath, $filename) ;$MailDoc.CREATERICHTEXTITEM($filename) EndIf ;Send the document $MailDoc.PostedDate = _Now();Gets the mail to appear in the sent items folder $MailDoc.SEND(0, $recipient) $Maildb = "NULL" $MailDoc = "NULL" $AttachME = "NULL" $Session = "NULL" $EmbedObj = "NULL" EndFunc ;==>SendNotesMail


To use it: change values of variables defined at the beginning

press F5 and enjoy :)

Again, many thanks to Raquien!

Thanks for posting this!

Do you know how to change it so that it will embed the document/picture with a preview on the email?

I imagine it would be between these two lines:

$AttachME = $MailDoc.CREATERICHTEXTITEM($filename) $EmbedObj = $AttachME.EMBEDOBJECT(1454, "", $fullpath, $filename)


Also how can I send two attachments?

Thanks!
  • goodmanjl531 likes this

#10 goodmanjl531

goodmanjl531

    Seeker

  • Active Members
  • 21 posts

Posted 23 August 2013 - 01:56 PM

Thanks for posting this!

Do you know how to change it so that it will embed the document/picture with a preview on the email?

I imagine it would be between these two lines:
 

$AttachME = $MailDoc.CREATERICHTEXTITEM($filename) $EmbedObj = $AttachME.EMBEDOBJECT(1454, "", $fullpath, $filename)

Also how can I send two attachments?

Thanks!

 

This script is works great to send right away ... I would like to create an mail msg without actually sending it right away so i can edit the Body text, Any ideas???

 

Thanks!



#11 water

water

    ?

  • MVPs
  • 15,730 posts

Posted 23 August 2013 - 02:05 PM

I think you simply need to remove this part:

;Send the document $MailDoc.PostedDate = _Now();Gets the mail to appear in the sent items folder $MailDoc.SEND(0, $recipient) $Maildb = "NULL" $MailDoc = "NULL" $AttachME = "NULL" $Session = "NULL" $EmbedObj = "NULL"

UDFs:
Active Directory (NEW 2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

#12 goodmanjl531

goodmanjl531

    Seeker

  • Active Members
  • 21 posts

Posted 23 August 2013 - 02:34 PM

I tired above and nothing happens at all

 

i found this script in VB -->

Plain Text         
Hi, The code down below helps me attach documents to lotus mails. Also, it does not send the newly created mail immediately, it shows up in the Notes window as a new memo. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click         Dim Maildb As Object 'The mail database         Dim MailDoc As Object 'The mail document itself         Dim AttachME As Object 'The attachment richtextfile object         Dim Session As Object 'The notes session         Dim EmbedObj As Object 'The embedded object (Attachment)         Dim uiWorkspace As Object 'The Notes Workspace         Dim uiDoc As Object 'The UI document         Dim strServer As String 'Server Name         Dim strFileName As String 'File Name         Dim strFile As String 'File to be attached to the mail         Try             'Start a session to notes             Session = CreateObject("Notes.NotesSession")             'Create a Workspace             uiWorkspace = CreateObject("Notes.NotesUIWorkspace")             Maildb = Session.GetDatabase("", "")             Maildb.OpenMail()             strServer = Maildb.Server             strFileName = Maildb.FilePath             If Maildb.IsOpen = False Then                 Maildb.OPENMAIL()             End If             'Set up the new mail document             MailDoc = Maildb.CREATEDOCUMENT             With MailDoc                 .Form = "Memo"                 .sendto = "abc@xyz.com"                 .Subject = "Test Subject"                 .Body = "Test Body"                 '.SAVEMESSAGEONSEND = saveit             End With             'Set up the embedded object and attachment and attach it             strFile = "c:\error.doc"             If strFile <> "" Then                 AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")                 EmbedObj = AttachME.EMBEDOBJECT(1454, "", strFile, "Attachment")             End If             'Create and Open a NotesUIDocument Instance             uiDoc = uiWorkspace.EditDocument(True, MailDoc)         Catch caught As Exception             MessageBox.Show(caught.Message)         Finally             'Clean(Up)             Maildb = Nothing             MailDoc = Nothing             AttachME = Nothing             Session = Nothing             EmbedObj = Nothing         End Try     End Sub :thumb: Suraj





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users