Adding customised attachment in macro


I want to add customized attachments to this coding. I managed to create file via loop but not able to attach the same in macro while sending emails from lotus notes

Sub SendMail()

    Dim Notes, db, WorkSpace
    Dim UIdoc, UserName, MailDbName
    Dim strAttachment As String
    Dim emp As String
    Dim empfile As String
    Dim AttachME As Object 'The attachment richtextfile object
    Dim EmbedObj As Object 'The embedded object (Attachment)

    Set Notes = CreateObject("Notes.NotesSession")
    emp = Sheet4.Cells(6, 3)
    empfile = "" + emp + ".xlsx"

    UserName = Notes.UserName
    MailDbName = Left(UserName, 1) & Right(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"

    Set db = Notes.GETDATABASE(vbNullString, MailDbName)

    Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
    Call WorkSpace.ComposeDocument(, , "Memo")
    toid = Sheet4.Cells(6, 3)
    ccid = Sheet4.Cells(12, 3)
    strAttachment = "E:\CTG MIS\Score Card\" + empfile
    Set UIdoc = WorkSpace.CurrentDocument
    Call UIdoc.FieldSetText("EnterSendTo", toid) 'Recipient
    Call UIdoc.FieldSetText("EnterCopyTo", ccid) 'Recipient
    subj = Sheet4.Cells(1, 3)
    Call UIdoc.FieldSetText("Subject", subj)

    Selection.CopyPicture xlScreen, xlBitmap
    Call UIdoc.GotoField("Body")
    Call UIdoc.SelectAll
    Call UIdoc.Paste
    Application.CutCopyMode = False

    Call UIdoc.SEND(False)
    Set UIdoc = Nothing: Set WorkSpace = Nothing
    Set db = Nothing: Set Notes = Nothing

End Sub


Please only use Code tags only around code. Also, please try not to double-post. I updated your formatting and deleted the second post for you.
don (rep: 1745) Jun 30, '19 at 11:31 pm
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login