Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-21-2022, 07:51 PM
trevorc trevorc is offline VBA code looks ugly, but works ok, needs a going over to neaten it up. Windows 7 32bit VBA code looks ugly, but works ok, needs a going over to neaten it up. Office 2013
Competent Performer
VBA code looks ugly, but works ok, needs a going over to neaten it up.
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default 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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code looks ugly, but works ok, needs a going over to neaten it up. How before and After spacing works got_word:-] Word 6 08-06-2018 11:45 AM
VBA code looks ugly, but works ok, needs a going over to neaten it up. Works to word Janette Word 1 11-12-2011 08:23 AM
VBA code looks ugly, but works ok, needs a going over to neaten it up. .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
VBA code looks ugly, but works ok, needs a going over to neaten it up. MS Works 2000 mommu Office 4 01-23-2006 02:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft