Outlook 2010 VBA Coding Assistance please!

Status
Not open for further replies.

gazcicini

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
Hi all new to the forum although I have used the site many times over the years. I am looking for a little help to expand my Macro script to add more functionality.

Currently I have a custom button that when pressed creates an email as follows:

Sub EMAIL_FORMAT()
Set myFolder = Session.GetDefaultFolder(olFolderInbox)
Set myItem = myFolder.Items.Add("IPM.Note.mail")
myItem.Display
With myItem
.CC = "example@email.co.uk"
.Subject = Format(Now, "yyyy-mm-dd") & " 1234 ABC"
.Display
End With
End Sub


What I am trying to do is a second button that will add the following info to a highlighted "blue" email that I would like to forward. Unfortunately its a little to complex for me. I have read numerous examples of forwarding code but cannot seem to solve. Any help greatly appreciated.


.To = "example@email.co.uk"
.Subject = Format(Now, "yyyy-mm-dd") & " 1234 ABC" & Keep the existing email header text




Regards,

gaz
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
To forward, you would need to get the selected item then forward:

Code:
 Sub forwardmacro()
Set Item = Application.ActiveExplorer.Selection.Item(1)
Set myForward = Item.Forward
myForward.Recipients.Add "alias@domain.com"
myForward.Subject = Format(Now, "yyyy-mm-dd") & " 1234 ABC" & item.subject
myForward.Display
End Sub
(You could use .To instead of recipients add.)
 
Last edited:

gazcicini

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
Thanks for the quick response I will give a try and let you know how I get on.

Regards,
 

gazcicini

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
upload_2015-9-16_13-37-34.png

[DOUBLEPOST=1442407170][/DOUBLEPOST]Hi I pasted this code in and get a debug message on the second line. Any ideas why as much as I want to get this to work I also want to understand why it works.

Thanks
upload_2015-9-16_13-39-24.png
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Array index means the item identified as the first one in the selection isn't found - but I'm not able to repro it, as you should always have something selected. The (1) means the first selection, so it works even if you select multiple messages - if you change it to (4) and select 3 items, it'll trigger that error because there isn't a 4th item in the selection.

Plus... you need to use either item or myitem... but that will give you error #424 on the next line. if you had a contact or appointment selected, you'd get #438...


BTW, if you want to keep the existing subject, add & item.subject at the end of the subject line.
 

gazcicini

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
After understanding what the code means from your description above I now have my Macro fully working and have set it up from a custom button.

Thank you.

gaz
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
dweller Outlook 2010 Rule Ignores VBA Script Outlook VBA and Custom Forms 2
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
D Change sender name outlook vba 2010 Custom Userform Outlook VBA and Custom Forms 1
N VBA Script to Send Automatic Emails from Outlook 2010 Outlook VBA and Custom Forms 1
G Outlook 2003 VBA Won't Run In Outlook 2010 Outlook VBA and Custom Forms 4
R How to copy outlook 2010 shared calendar appointment or meeting to personal calendar by vba? Outlook VBA and Custom Forms 1
L Outlook 2010 VBA issue Using Outlook 1
M VBA code needed to move from Outlook 2010 subfolder to Symantec Vault subfolde Using Outlook 0
B Excel 2010 vba to post appts to different outlook calendars at the same time Using Outlook 6
M Updating VBA code from outlook 2007 to outlook 2010 Using Outlook 1
R Add category via VBA in Outlook 2010 x64 not working? Exchange Server Administration 3
e_a_g_l_e_p_i I think it may be time to upgrade from Outlook 2010 Using Outlook 3
T Why does outlook 2010 convert only some forum notifications to plain text? Using Outlook 2
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
M Outlook 2010 Problem with OutLook 2010 32 bit, after Windows Auto Update Using Outlook 3
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
D Outlook 2010 account setup fails in particular domain Using Outlook 3
B Outlook 2010 is Auto Purging when not configured for that Using Outlook 1
W Outlook 2010 Reading Pane Slows Startup Using Outlook 3
S Outlook 2010 unable to change default font Using Outlook 7
B Outlook 2010 Can not find a certain file in M/S Outlook 2010. Using Outlook 1
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
W Outlook 2010 some sent items marked unread now (was Ok before) Using Outlook 0
RBLampert Updating from Outlook 2010 to Outlook 365 Using Outlook 0
L What are the risks of opening an Outlook 2016 .pst file in Outlook 2010? Using Outlook 4
S Unable to remove rule outlook 2010 Using Outlook 0
N Outlook 2010 Flag blocked for Safe Senders List???? Using Outlook 7
Mark Foley Unable to subscribe to published calendar in Outlook 2010 Using Outlook 4
K Maximum Categorize Shortcuts In Outlook 2010? Using Outlook 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
RBLampert Outlook 2010 no longer (?) shrinks large images Using Outlook 4
N Outlook 2010 will not send nor receive Using Outlook 4
U Outlook 2010 'freezes' before moving emails Using Outlook 2
P Outlook 2010 trusted emails going to spam folder Using Outlook 18
E Outlook 2010 Subject sort uses Thread-Topic for grouping Using Outlook 2
King Mustard Maximum Categorize shortcuts in Outlook 2010? Using Outlook 1
C Outlook 2010 keeps asking for username and password Using Outlook 1
M Duplicate Primary Mail Accounts outlook 2010 Using Outlook 0
T Compacting Outlook 2010 OST results in old emails being re-sent Using Outlook 6
K Outlook 2010 duplicate download emails 1 inbox 1 PST no updates Using Outlook 3
Potty Ash MS Outlook 2010 custom form - validation or formula to request user to check a checkbox Outlook VBA and Custom Forms 16
RBLampert Outlook 2010 sends to/receives from some Gmail addresses but not others Using Outlook 3
e_a_g_l_e_p_i Question about address book in Outlook 2010 Using Outlook 9
e_a_g_l_e_p_i Is there a good third party SPAM filter that intergrates with Outlook 2010 Using Outlook 7
e_a_g_l_e_p_i Another reinstall of Outlook 2010 issue Using Outlook 10
S Outlook 2010 Cannot Open Attachments Using Outlook 14
Justo Horrillo Issue with rules in Outlook 2010 Using Outlook 4
L Upgrade from Outlook 2010-any reason to? Using Outlook 1
C Attached Files outlook 2010 Using Outlook 1
C Attached files on Outlook 2010 Sp1 & Exc 2013 are missing Exchange Server Administration 1
Similar threads


















































Top