Hi all,
I've been reading some posts about my question over the internet but didn't find any accurate answer.
Here's the problem:
When I click a button in Excel, i need the table from a certain "Range" to copy/paste in the body of an e-mail that will send itself automatically.
Now, I know how to build the macro to automatically send the e-mail but I can't find a way to insert the table in it.
Here's the code I'm using to send the e-mail:
Public Sub SendMail2()
'Tools --> references --> Microsoft Scripting runtime
'Variables
Dim EMailSendTo As Variant
Dim EMailCCTo As Variant
Dim EMailBCCTo As Variant
Dim EmailSubject As String
Dim rnBody As Range
On Error Resume Next
'Recipients
EMailSendTo = VBA.Array("recipient@bbb.com")
EMailCCTo = VBA.Array("")
EMailBCCTo = VBA.Array("")
EmailSubject = "TEST"
Set objNotesSession = CreateObject("Notes.NotesSession")
Set objNotesMailFile = objNotesSession.GETDATABASE("", "")
objNotesMailFile.OPENMAIL
Set objNotesDocument = objNotesMailFile.CREATEDOCUMENT
Set objNotesField = objNotesDocument.APPENDITEMVALUE("Subject", EmailSubject)
Set objNotesField = objNotesDocument.CREATERICHTEXTITEM("Body")
objNotesField.APPENDTEXT "" & vbCr
Set objNotesField = objNotesDocument.APPENDITEMVALUE("SendTo", EMailSendTo)
Set objNotesField = objNotesDocument.APPENDITEMVALUE("CopyTo", EMailCCTo)
Set objNotesField = objNotesDocument.APPENDITEMVALUE("BlindCopyTo", EMailBCCTo)
objNotesDocument.send (0)
Set objNotesSession = Nothing
Set objNotesSession = Nothing
Set objNotesMailFile = Nothing
Set objNotesDocument = Nothing
Set objNotesField = Nothing
End Sub
I read somewhere that you can use this code:
Range([b5], [b65536].End(3)).CopyPicture
Call UIdoc.GotoField("Body")
'Blah blah blah
Call UIdoc.Paste
But I don't know how to adapt the code for my problem. The fact is, I've just started to write macros and the code I'm using for the e-mail isn't from me, I have just adapted it for my problem. If you guys could help me, that would be really appreciated!
Thanks in advance guys.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: