Lotus notes body image alignment not happening

Balvinder Rayat

New Member
Joined
Nov 21, 2011
Messages
6
Hi,

I'am using below code to send automated mail by copying range from excel. But image (excel range) which is getting copied from excel range & pasted in Lotus notes new document is aligned to left. I want to make this "Center".

any help on this..!!!
Code:
Public Function SendEMail()

Dim thisWB  As String
Dim newWB As String
Dim Email As String
Dim SendTo As String
Dim EmailSubject As String
Dim MyAttachment As String


    thisWB = ActiveWorkbook.Name
    
    On Error Resume Next
    Sheets("tempsheet").Delete
    On Error GoTo 0
    
    Sheets.Add
    ActiveSheet.Name = "tempsheet"
    Sheets("Data").Select
    
    If ActiveSheet.AutoFilterMode Then
        Cells.Select
        On Error Resume Next
        ActiveSheet.ShowAllData
        On Error GoTo 0
    End If
    
    Columns("A:A").Select
    Selection.Copy
    
    Sheets("tempsheet").Select
    Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    
    
    If (Cells(1, 1) = "") Then
        lastrow = Cells(1, 1).End(xlDown).Row
        
        If lastrow <> Rows.Count Then
            Range("A1:A" & lastrow - 1).Select
            Selection.Delete Shift:=xlUp
        End If
    
    End If
    
    Columns("A:A").Select
    Columns("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("B1"), Unique:=True
    
    Columns("A:A").Delete
    
    Cells.Select
    Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
    
    lMaxSupp = Cells(Rows.Count, 1).End(xlUp).Row
    
    For suppNo = 2 To lMaxSupp
    
        Windows(thisWB).Activate
        SupName = Sheets("tempsheet").Range("A" & suppNo)
        
        If SupName <> "" Then
            
            Sheets("Data").Select
            Cells.Select
            
            ActiveSheet.Range("$A$1:$E$65000").AutoFilter Field:=1, Criteria1:="=" & SupName
            
            Columns("A:E").Select
            Range(Selection, Selection.End(xlUp)).Select
            Selection.Copy
            Sheets("Sheet5").Select
            Range("A1").Select
            ActiveSheet.Paste
            Cells.Select
            Cells.EntireColumn.AutoFit
            
            'Storing e-mail id into Email variable where email need to be sent
            Email = Range("E2").Value
            
            Range("A2:D2").Select
            Application.CutCopyMode = False
            Selection.Copy
            Sheets("Range").Select
            Range("B23").Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            Range("A1").Select
        End If
            
  
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
    End With
   
   '********************************************************************************************
   
SendEMail = True

Dim myRange As Range

'Set E-mail format range
    Worksheets("Range").Activate
    Worksheets("Range").Range("A1:F44").Select
    Worksheets("Range").Range("A1:F44").Copy

'On Error GoTo ErrorMsg
   
    Dim EmailList As Variant
    Dim ws, uidoc, session, db, uidb, NotesAttach, NotesDoc, objShell As Object
    Dim RichTextBody, RichTextAttachment As Object
    Dim server, mailfile, user, usersig As String
    Dim SubjectTxt, MsgTxt As String
           
    Set session = CreateObject("Notes.NotesSession")
    If session Is Nothing Then
        MsgBox "Sorry, unable to instantiate the Notes Session", vbOKOnly, "Unable to Continue"
        SendEMail = False
    End If
   
    user = session.UserName
    usersig = session.CommonUserName
    server = ""
    mailfile = session.GetEnvironmentString("MailFile", True)
   
    Set db = session.GetDatabase(server, mailfile)
    If Not db.IsOpen Then
        Call db.Open("", "")
        Exit Function
    End If
           
    If Not db.IsOpen Then
        MsgBox "Sorry, unable to open: " & mailfile, vbOK, "Unable to Continue"
        SendEMail = False
    End If
    
    Set NotesDoc = db.createdocument
    
    With NotesDoc
        .form = "Memo"
        .Subject = "ECS Transaction Pre-Hit Intimation" 'The subject line in the email
        .Principal = user
        .SendTo = Email  'e-mail ID variable to identify whom email need to be sent
    End With
    
    Set RichTextBody = NotesDoc.CreateRichTextItem("Body")
        
   With NotesDoc
        .computewithform False, False
        '.SAVEMESSAGEONSEND = True
        .Doc_Category = "Business Secret"
        '.Save True, False, True
    End With
        
   'Now set the front end stuff
   Set ws = CreateObject("Notes.NotesUIWorkspace")
   If Not ws Is Nothing Then
   Set uidoc = ws.editdocument(True, NotesDoc)
   
    If Not uidoc Is Nothing Then
         If uidoc.editmode Then
           Call uidoc.gotofield("Body")
           Call uidoc.Paste
         End If
     End If
   End If
   
   Call uidoc.SEND
    Call uidoc.Close
   
   With NotesDoc
        .Doc_Category = "Business Secret"
        .PostedDate = Now()
        '.Save True, False, True
        '.SaveOptions = "0"
        '.SEND False
   End With
    
   
   'close connection to free memory
    Set session = Nothing
    Set db = Nothing
    Set NotesAttach = Nothing
    Set NotesDoc = Nothing
    Set uidoc = Nothing
    Set ws = Nothing
    
'ErrorMsg:
'    SendEMail = False
'    If Err.Number = 7225 Then
'            MsgBox "The file " & Range("Fname_NZ_VaR") & " cannot be found in the location " & Range("Path_NZ_VaR"), vbOKOnly, "Error"
'    ElseIf Err.Number = 1004 Then
'            MsgBox "One of the following may be causing an error:" & vbCrLf & "1. The range 'Path_NZ_VaR' and/or 'Fname_NZ_VaR' does not exist in this spreadsheet," & _
'            vbCrLf & "2. The range 'Fname_NZ_VaR' does not contain a filename," & vbCrLf & "3. The path " & Range("Path_NZ_VaR") & " does not exist.", vbOKOnly, "Error"
'    Else
'            MsgBox Err.Number & Err.Description
 '   End If

'Exit Function
   
Next
            Sheets("tempsheet").Delete
            Sheets("Total Data").Select
    
            If ActiveSheet.AutoFilterMode Then
                Cells.Select
                ActiveSheet.ShowAllData
            End If
End Function
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Have you looked at the options for alignment, if there are any, for placing an image into the email body?

Is it an image you are placing?
 
Upvote 0
Yes norie,

I've tried to build something but didn't worked. Actually i don't know what is the property which i can use there in code to align Centered.

and yes, it's an image which is getting copied from Excel sheet range.
 
Upvote 0
Look at NotesRichTextParagraphStyle with property Alignment = ALIGN_CENTER. With this style appended to a NotesRichTextItem the following paragraph will be centred.
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,065
Members
448,941
Latest member
AlphaRino

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top