Hi,
I wonder if anyone could help me with tweaking some code for sending an email with range and text.
I'm nearly there but got stuck at one thing which hopefully will be an easy thing for more experienced users.
I'm still in a "don't know what I'm doing" phase but gone through numerous tutorials and managed to put together a code that kinda does the thing that I want but not in the right order.
The code below selects and copies a range (dynamic - spitted out into a sheet by another piece of code - thus the formula), creates an email, put all the greetings and question first but pastes the range below the signature.
Could you suggest the change so it pastes the range between the question and the signature please?
I appreciate any suggestions.
Here's the code:
>>> use code - tags <<<
Thanks a lot,
Rafal
I wonder if anyone could help me with tweaking some code for sending an email with range and text.
I'm nearly there but got stuck at one thing which hopefully will be an easy thing for more experienced users.
I'm still in a "don't know what I'm doing" phase but gone through numerous tutorials and managed to put together a code that kinda does the thing that I want but not in the right order.
The code below selects and copies a range (dynamic - spitted out into a sheet by another piece of code - thus the formula), creates an email, put all the greetings and question first but pastes the range below the signature.
Could you suggest the change so it pastes the range between the question and the signature please?
I appreciate any suggestions.
Here's the code:
>>> use code - tags <<<
Code:
Sub EmailGRE05()
'
' EmailGRE05 Macro
'
Dim R As Range
Set R = Range("A1").CurrentRegion
R.Select
Selection.Copy
Dim emailApplication As Object
Dim emailItem As Object
Dim xInspect As Object
Dim pageEditor As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
emailItem.to = "email@company.com"
emailItem.Subject = "Transfer Prices for Europe (ICP3)"
emailItem.Body = "Hi," & vbNewLine & vbNewLine & "Could you advise on some prices for Europe please?" & vbNewLine & vbNewLine & "Thanks," & vbNewLine & "Rafal"
emailItem.display
Set xInspect = emailItem.GetInspector
Set pageEditor = xInspect.WordEditor
pageEditor.Application.Selection.Start = Len(emailItem.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatRichText)
emailItem.display
'
End Sub
Rafal
Last edited by a moderator: