Jump to content

generating an email with an attachment


gcue
 Share

Recommended Posts

i am trying to generate (not send) an email with an attachment

currently, im using _inetmail but it doesnt provide an attachment option. i also saw Jos's awesome udf for sending an email using the smtp server settings.

i just want to create an email and attach a file - let the user type in recipient and click send

any ideas??

(using lotus notes)

many thanks

Link to comment
Share on other sites

I use the following code for Outlook:

$oOApp = ObjCreate("Outlook.Application")
        $oOMail = $oOApp.CreateItem($olMailItem)
    
        With $oOMail
            .To = ($MailAn)
            .Subject = "blah blah"
            .BodyFormat = 2 ; $olFormatHTML
            .Importance = 2 ; $olImportanceHigh
            .HTMLBody = '<span style="font-family:Arial;font-size:10pt">' & _
                'The files in Directory' & _
                '<P><a href="file:///' & $Target & '">' & $Target & '</a>' & _
                '<P>have changedt.'
            .Display
;   .Send
        EndWith

I don't know if there is something similar for Notes.

Edit:

Searching the forum I found this.The mentioned IBM redbook "COM Togehter - with Domino" can be found here.

This post even has a script example.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

thanks for the response!

theres ObjCreate("Notes.NotesSession")

tried this but didnt work:

$oOApp = ObjCreate("Notes.Session")
        $oOMail = $oOApp.CreateItem($olMailItem)

        With $oOMail
            .To = ($MailAn)
            .Subject = "blah blah"
            .BodyFormat = 2 ; $olFormatHTML
            .Importance = 2 ; $olImportanceHigh
            .HTMLBody = '<span style="font-family:Arial;font-size:10pt">' & _
                'The files in Directory' & _
                '<P><a href="file:///' & $Target & '">' & $Target & '</a>' & _
                '<P>have changedt.'
            .Display
;   .Send
        EndWith
Edited by gcue
Link to comment
Share on other sites

this worked =) (found a vbs script and converted it)

sends the email though =/ and mailfile has to be opened..

$oSession = ObjCreate("Notes.NotesSession")
$oCurrentMailDb = $oSession.CurrentDatabase

    ; Create a document in the back end

     $oMailDoc = $oCurrentMailDb.CREATEDOCUMENT
     $ortItem = $oMailDoc.CREATERICHTEXTITEM("Body")

    with $ortItem

        .AppendText("Here are the logs you requested for ")

;~         .AddNewLine(2)

;~         .AppendText("Please let me know if you need anything else.")

    EndWith


    $cstrAttachment = "c:\aclient.cfg"
    $blAttachment = 1

    If $blAttachment Then
         $ortAttacment = $oMailDoc.CREATERICHTEXTITEM("Attachment")

        ; Function EMBEDOBJECT(ByVal TYPE As Short, ByVal CLASS As String, ByVal SOURCE As String, Optional ByVal OBJECTNAME As Object = Nothing) As Object

        ; Member of lotus.NOTESRICHTEXTITEM

         $oEmbedObject = $ortAttacment.EMBEDOBJECT(1454, "", $cstrAttachment, "Attachment")
     EndIf
     
        With $oMailDoc
            .SendTo = "test@test.com"
            .Subject = "Logs for"
            .BodyFormat = 2 ; $olFormatHTML
;~             .Importance = 2 ; $olImportanceHigh
;~             .HTMLBody = '<span style="font-family:Arial;font-size:10pt">' & _
;~                 'The files in Directory' & _
;~              '<P><a href="file:///' & $Target & '">' & $Target & '</a>' & _
;~                 '<P>have changedt.'
            .Display
            .Send(0)
        EndWith
Edited by gcue
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...