#1
|
|||
|
|||
VBA code looks ugly, but works ok, needs a going over to neaten it up.
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 |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How before and After spacing works | got_word:-] | Word | 6 | 08-06-2018 11:45 AM |
Works to word | Janette | Word | 1 | 11-12-2011 08:23 AM |
.OnAction only works in document with the code | donbexcel | Word VBA | 1 | 11-02-2011 05:25 AM |
Converting from Works | Menno Hershberger | Office | 0 | 09-01-2010 11:33 PM |
MS Works 2000 | mommu | Office | 4 | 01-23-2006 02:40 PM |