我有10列数据,行数不同,通过电子邮件发送无格式范围。我希望能够用空格右键填充每列中的单元格,以便未格式化的范围以均匀的间隔复制。范围未格式化的原因是我使用的是LotusNotes,而且我没有像Outlook一样的集成选项。无论如何没有添加我可以用空格字符填充单元格的列,所以在电子邮件中范围看起来不错?
编辑:这样我就可以通过输入框输入电子邮件并选择一个范围。它将创建电子邮件并发送,但它不会保留单元格格式(即间距)可以这样做吗?我曾尝试使用MIME实体来使用HTML,但我不确定如何将范围复制到HTML正文中
更新代码:
Sub Lotus_Email()
Dim noSession As Object, noDatabase As Object, noDocument As Object
Dim vaRecipient As String
Dim rnBody As Range
Dim Data As DataObject
Const stSubject As String = "EMAIL SUBJECT"
Const stMsg As String = "Please review the following Purchase Orders and advise."
Const stPrompt As String = "Please select the range:"
'This is one technique to send an e-mail to many recipients but for larger
'number of recipients it's more convenient to read the recipient-list from
'a range in the workbook.
vaRecipient = InputBox("Please enter an e-mail address", "E-Mail Address Entry")
On Error Resume Next
Set rnBody = Application.InputBox(Prompt:=stPrompt, _
Default:=Selection.Address, Type:=8)
'The user canceled the operation.
If rnBody Is Nothing Then Exit Sub
On Error GoTo 0
'Instantiate Lotus Notes COM's objects.
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'Make sure Lotus Notes is open and available.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Create the document for the e-mail.
Set noDocument = noDatabase.CreateDocument
'Copy the selected range into memory.
rnBody.Copy
Set rtItem = noDocument.CreateRichTextItem("Body")
With rtItem
.appendtext ("LINE 1")
.addnewline (2)
.appendtext ("LINE 2")
.addnewline (2)
.addnewline (1)
.appendtext ("Please review and respond to the email noted above")
.appendtext ("TEST")
rnBody.PasteSpecial
End With
'Add data to the mainproperties of the e-mail's document.
With noDocument
.Form = "Memo"
.SendTo = vaRecipient
.Subject = stSubject
'Retrieve the data from the clipboard.
' NON-HTML BODY OFF
' .Body = stMsg & vbCrLf & vbCrLf & vbCrLf & vbCrLf & Data.GetText
.SaveMessageOnSend = True
End With
'Send the e-mail.
With noDocument
.PostedDate = Now()
.Send 0, vaRecipient
End With
'Release objects from memory.
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
'Activate Excel for the user.
AppActivate "Microsoft Excel"
'Empty the clipboard.
Application.CutCopyMode = False
MsgBox "The e-mail has successfully been created and distributed.", vbInformation
End Sub
答案 0 :(得分:0)
UNTESTED。也许这样的事情?:
=A1&REPT(" ",25-LEN(A1))
答案 1 :(得分:0)
因此在使用LotusNotes MIME之后我可以导入Rich Text,但是它不会保留列宽和excel格式。我创建了一个带有我的范围选择的临时工作簿,并将其作为附件附加。这似乎是使用LotusNotes处理此问题的方法。