Consulting

Results 1 to 4 of 4

Thread: Solved: Help on how VBA could attach file to Lotus Notes Email template and save to drafts

  1. #1
    VBAX Newbie
    Joined
    Jun 2008
    Posts
    3
    Location

    Solved: Help on how VBA could attach file to Lotus Notes Email template and save to drafts

    Hi All,

    Does anyone knows how to attach a file into an email template of lotus notes and save to drafts folder without sending it?

    Need help

    Thanks,

  2. #2
    VBAX Contributor
    Joined
    Jun 2008
    Location
    West Midlands
    Posts
    170
    Location
    Quote Originally Posted by fgm1215
    Hi All,

    Does anyone knows how to attach a file into an email template of lotus notes and save to drafts folder without sending it?

    Need help

    Thanks,
    Hi,

    This code will allow you to attach a file to a Lotus Notes email and send it, you are welcome to try and modify it so it only saves as draft and does not send.

    [VBA]Sub email()
    Dim noSession As Object, noDatabase As Object, noDocument As Object
    Dim obAttachment As Object, EmbedObject As Object
    Dim stSubject As Variant
    Dim stAttachment As String

    Dim vaRecipient As Variant, vaMsg As Variant

    Const EMBED_ATTACHMENT As Long = 1454

    ' Starts the For Next loop to assign variable email target
    For e = 1 To 3
    If e = 1 Then vaRecipient = "scott.atkinson@poundland.co.uk"
    If e = 2 Then vaRecipient = "neil.maher@poundland.co.uk"
    If e = 3 Then vaRecipient = "helen.allsop@poundland.co.uk"
    On Error GoTo SendMailError

    vaMsg = "THIS AN AUTOMATED EMAIL ----- " ' Put your Body text here
    stSubject = "*** Essentials Availability Report ***" ' Put your subject text here

    stAttachment = "I:\H925 Buying\Scott Atkinson\Projects\Helen's Availability Project\Essentials Availability.xls" ' Define your attached file here

    'Instantiate the Lotus Notes COM's Objects.
    Set noSession = CreateObject("Notes.NotesSession")
    Set noDatabase = noSession.GETDATABASE("", "")
    'If Lotus Notes is not open then open the mail-part of it.
    If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
    'Create the e-mail and the attachment.
    Set noDocument = noDatabase.CreateDocument
    Set obAttachment = noDocument.CreateRichTextItem("stAttachment")
    Set EmbedObject = obAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
    'Add values to the created e-mail main properties.
    With noDocument
    .Form = "Memo"
    .SendTo = vaRecipient
    .Subject = stSubject
    .Body = vaMsg
    .SaveMessageOnSend = True
    End With
    'Send the e-mail.
    With noDocument
    .PostedDate = Now()
    .Send 0, vaRecipient
    End With

    Next e
    GoTo line1

    SendMailError:
    Dim Msg
    Msg = "Error # " & Str(Err.Number) & " was generated by " _
    & Err.Source & Chr(13) & Err.Description
    MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
    'SendMail = False
    line1:
    End Sub
    [/VBA]

  3. #3
    VBAX Regular
    Joined
    Feb 2008
    Posts
    32
    Location
    Try following some of the code in this link, it should get you pretty close:

    http://www.ozgrid.com/forum/showthread.php?t=18259

  4. #4
    VBAX Newbie
    Joined
    Sep 2012
    Posts
    1
    Location
    thank you,
    works like a charm even with team mailboxes after slight editing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •