Hi All,
Just started dipping into VBA for Outlook, have been using it for Excel and Access for some time.
I managed to put together this code from several places and it works ok, but looks like a mess of bits. Is there an easier/neater way to write this.
Code:
Sub SendMailItem() ' Send email to remove from hold selected RMA by Number
Dim item As Outlook.MailItem
Dim sct As Outlook.Selection
Dim byt As Byte
Dim OutApp As Object
Dim outmail As Object
Dim msgbody As String
Dim objol, objmsg, objforward, objOrignialBody, objsubject
Dim myInspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set sct = Application.ActiveExplorer.Selection
Set item = sct(1)
item.Display
Set outmail = OutApp.ActiveInspector.CurrentItem
Set myInspector = Application.ActiveInspector
Set myItem = myInspector.CurrentItem
Set objol = CreateObject("Outlook.Application")
Set objmsg = objol.ActiveInspector.CurrentItem
Set objforward = objmsg.Forward
msgbody = outmail.Body
outmail.Body = "Thankyou." & vbNewLine & vbNewLine & vbNewLine & msgbody
objforward.Recipients.Add "t@.com.au" '"t@.com.au"
objOrignialBody = objforward.Body
DraftEmail:
objforward.Subject = "Re: " & objforward.Subject
objforward.Body = "Thankyou " & objforward.Body
objforward.Display
'objforward.Send
Set outmail = Nothing
Set OutApp = Nothing
myItem.Close olSave
End Sub