• adding code

    By robert allisonn 2 decades ago

    hello. i'm a new user to this forum. i was sent some code from somebody on a forum for a company that we use for our email filtering (postini). this code is supposed to automate the process of send an email as an attachment. outlook has this capability but i guess lotus notes doesn't. here's the code. could somebody help me add it? i don't know where or what database it need to be applied to. thanks



    "This code originally came from the Open NTF mail template. Be sure to update the relevant fields.



    Sub Initialize

    Dim sess As New NotesSession

    Dim ws As New NotesUiWorkspace

    Dim db As NotesDatabase

    Dim dc As NotesDocumentCollection

    Dim doc As NotesDocument

    Dim memo As notesdocument

    Dim mime As NotesMIMEEntity

    Dim stream As notesstream

    Dim mimeBoundaryEnd As String, mimeBoundarystart As String, exportFileName As String, directory As String, macro As String

    Dim mimeType As String, pathName As String

    Dim tmp As Variant

    Dim fileNum As Integer, records As Integer

    Dim rtItem As notesrichtextitem



    ' init

    Set db = sess.CurrentDatabase

    sess.ConvertMIME = False ' Do not convert MIME to rich text

    Set dc = db.UnprocessedDocuments

    Set doc = dc.GetFirstDocument

    directory$ = sess.GetEnvironmentstring("Directory",True)

    fileNum% = Freefile()

    records% = 0



    ' create the forwarding memo

    Set memo = db.CreateDocument

    memo.form = "Memo"

    Set rtItem = New notesRichTextItem(memo,"Body")



    While Not(doc Is Nothing)

    Set mime = doc.GetMIMEEntity

    If Not(mime Is Nothing) Then

    Set stream = sess.Createstream

    pathName$ = doc.subject(0)

    macro$ = {@Ascii( "} + doc.subject(0) + {" ) }

    tmp = Evaluate(macro$)

    macro$ = {@replacesubstring("} + tmp(0) + {";":":"?":"!";"")}

    tmp = Evaluate(macro$)

    exportFileName$ = directory$ + "\" + tmp(0) + ".eml"

    ' exportFileName$=directory$+"\"+"email.txt"

    If Dir$(exportFileName$) "" Then

    Kill exportFileName$

    End If

    Call stream.Open(exportFileName$, mime.Charset)

    mimeType = mime.ContentType

    mimeBoundarystart = mime.Boundarystart

    mimeBoundaryEnd = mime.BoundaryEnd

    Call mime.GetEntityAsText(stream)

    Set mime=mime.GetNextEntity

    While Not (mime Is Nothing)

    Call stream.WriteText("",3)

    'Call stream.WriteText(multiMIME$,3)

    Call stream.WriteText(mime.Boundarystart)

    Call mime.DecodeContent()

    Call mime.EncodeContent( 1727 )

    Call mime.GetEntityAsText(stream)

    Call stream.Writetext(mime.BoundaryEnd)

    Set mime=mime.GetNextEntity

    Wend

    Call stream.Writetext(mimeBoundaryEnd)

    Call stream.Close

    '=> attach file

    Call rtItem.embedobject(EMBED_ATTACHMENT,"",exportFileName$)

    '=> clean up

    Kill exportFileName$

    Else

    Messagebox doc.GetItemValue("subject")(0),,"Message is not an Internet email or has formatting problems."

    End If

    'Added, to move item to Junk out of inbox

    Call doc.PutInFolder("($JunkMail)",False)

    Call doc.RemoveFromFolder( "($Inbox)" )



    Set doc = dc.GetNextDocument(doc)



    Wend

    sess.ConvertMIME = True ' Restore conversion



    ' open the forwarding memo

    'Where do you want to send reported spam to?

    memo.SendTo = "spam@postini.com"

    '

    memo.Subject = "Reported Spam"

    Call memo.ComputeWithForm(True,False)

    Call memo.Send( False )



    'Do you want an internal address to be notified when users do this?

    Dim adminmemo As notesdocument

    Set adminmemo = db.CreateDocument

    adminmemo.form = "Memo"

    adminmemo.subject=sess.CommonUserName & " has just submitted spam"

    adminmemo.sendto="YOUR ADMIN ACCOUNT"

    Call adminmemo.Send( False )



    Messagebox "The message(s) you selected have been reported to Postini, and moved to your Junk Mail folder.",0,"Thank you!"

    End Sub

    • Sigh. once again This is not a helpdesk ...

      By Thomas Schulte 2 decades ago

      This is a project called !!HELP!! which by itself is a helpdesk database.