Jump to content

Jos's Lotus Notes Email function help


Recommended Posts

Jos, or anyone that might see the problem. When I receive the emails from the following code it seems that the emails are limited to 75 characters per line. I have some lines that go just over and it is throwing off the formatting. When I look at the vbscript file, it creates everything on one line as it should be, but the actual email is only putting 75 characters on 1 line and then adds a new line for the rest. Any ideas? Thanks.

Here is Jos's original code I used:

Func SentNotesMsg($MsgTxt)
  FileDelete(@TempDir & "\NotesMsg.vbs")
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Dim recip(2)')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'recip(0) = "User1@????.com"')
;FileWriteLine(@tempdir & "\NotesMsg.vbs",'recip(1) = "User2@????.com"')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesSession = CreateObject("Notes.NotesSession")')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesMailFile = objNotesSession.GETDATABASE("", "")')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'objNotesMailFile.OPENMAIL')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesDocument = objNotesMailFile.CREATEDOCUMENT')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesField = objNotesdocument.APPENDITEMVALUE("Subject","*** Subject of the message")')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesField = objNotesdocument.APPENDITEMVALUE("SendTo", recip)')
;FileWriteLine(@tempdir & "\NotesMsg.vbs",'Set objNotesField = objNotesdocument.APPENDITEMVALUE("CopyTo", "user3@????.com")')
;FileWriteLine(@tempdir & "\NotesMsg.vbs",'Set objNotesField = objNotesdocument.APPENDITEMVALUE("BlindCopyTo", "User4@???.com")')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesField = objNotesdocument.CREATERICHTEXTITEM("Body")')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'With objNotesField')
  $array = StringSplit($MsgTxt, @LF)
  FileWriteLine(@TempDir & "\NotesMsg.vbs", '   .ADDNEWLINE 1')
  For $x = 1 To $array[0]
     FileWriteLine(@TempDir & "\NotesMsg.vbs", '    .ADDNEWLINE 1')
     FileWriteLine(@TempDir & "\NotesMsg.vbs", '    .APPENDTEXT "' & $array[$x] & '"')
  Next
; use to attach a file
;FileWriteLine(@TempDir & "\NotesMsg.vbs", '     .EMBEDOBJECT 1454, "", "c:\temp\file.txt"')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'End With')
; save the message in the Sent folder
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'objNotesdocument.SAVEMESSAGEONSEND = True')
; sent it and clean up
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'objNotesdocument.Send (0)')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesSession = Nothing')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set bjNotesSession = Nothing')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesMailFile = Nothing')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesDocument = Nothing')
  FileWriteLine(@TempDir & "\NotesMsg.vbs", 'Set objNotesField = Nothing')
; run the actual script
  $rc = RunWait(@ComSpec & ' /c Wscript.exe "' & @TempDir & '\NotesMsg.vbs" //T:30 > sent.log 2>&1', @TempDir, @SW_HIDE)
; test the Return code here
; if $rc = ? then
; cleanup file
  FileDelete(@TempDir & '\NotesMsg.vbs")
EndFunc;==>SentMsg
Edited by notta
Link to comment
Share on other sites

  • Developers

I am not sure when I posted this example, but it is probably a while ago before AutoIt3 had COM build-in.

Anyways, the thing that could go wrong here is when you use:

$array = StringSplit($MsgTxt, @LF)

... and $MsgTxt contains @CRLF 's as newline characters, it means that the array values still contain the @CR's.

That could be solved by doing:

$array = StringSplit(StringReplace($MsgTxt,@CR,""), @LF)

Also this statement: ' .ADDNEWLINE 1' will append an empty line so your code will have an empty line between each array text.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...