-
Feb 18th, 2014, 10:36 PM
#1
Thread Starter
Junior Member
Macro to copy subject line
I need a macro to copy subject line of the email from the reading pane itself and also another need a macro to copy email address of a "from sender" to a clipboard...both clipboard.
I already have clipboard dll installed. Please help me with the complete code...it is for outlook 2010..
-
Feb 19th, 2014, 01:10 AM
#2
Re: Macro to copy subject line
Here at vbforums, we do not give the complete code in a platter. Could you show us what have you tried and where are you stuck and we will definitely help you.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 19th, 2014, 01:21 AM
#3
Thread Starter
Junior Member
Re: Macro to copy subject line
Originally Posted by Siddharth Rout
Here at vbforums, we do not give the complete code in a platter. Could you show us what have you tried and where are you stuck and we will definitely help you.
Hi Siddharath,
I am a newbie and learning this VBscripting just on my own by following this forum. just to increase my productivity. I am really not sure what I can do other than surfing on google..but have not got anything that I was looking for. If you guys help it would be great.
Thank you.
-
Feb 19th, 2014, 06:05 AM
#4
Re: Macro to copy subject line
try like
Code:
Dim m As MailItem
Set m = ActiveExplorer.Selection(1)
s = m.Subject
f = m.SenderName
Set m = m.Reply
e = m.Recipients(1).Name
m.Close olDiscard
Set cb = CreateObject("clipbrd.clipboard")
cb.Clear
cb.settext s & vbNewLine & f & "[" & e & "]"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 19th, 2014, 08:17 AM
#5
Thread Starter
Junior Member
Re: Macro to copy subject line
Originally Posted by westconn1
try like
Code:
Dim m As MailItem
Set m = ActiveExplorer.Selection(1)
s = m.Subject
f = m.SenderName
Set m = m.Reply
e = m.Recipients(1).Name
m.Close olDiscard
Set cb = CreateObject("clipbrd.clipboard")
cb.Clear
cb.settext s & vbNewLine & f & "[" & e & "]"
First of all thank alot to westconn again for helping me....Sharing the knowledge is the greatest thing that you are doing westconn, I really appreciate your help.
Well I need seperate macros to perform this....the 1st to copy subj is working fine, the other seems to be copy the name from the address book rather than email..it should atleast copy first part of the email....is it possible...
Code:
Sub subj()
Dim m As MailItem
Set m = ActiveExplorer.Selection(1)
s = m.Subject
Set m = m.Reply
m.Close olDiscard
Set cb = CreateObject("clipbrd.clipboard")
cb.Clear
cb.SetText s & vbNewLine
End Sub
Code:
Sub getemail()
Dim m As MailItem
Set m = ActiveExplorer.Selection(1)
f = m.SenderName
Set m = m.Reply
e = m.Recipients(1).Name
m.Close olDiscard
Set cb = CreateObject("clipbrd.clipboard")
cb.Clear
cb.SetText f & vbNewLine
End Sub
-
Feb 19th, 2014, 03:45 PM
#6
Re: Macro to copy subject line
the senders email address is not included within the email, unless m.senderaddress works for you, it did not for me (maybe different in your version)
m.sendername only returns the name of the sender, not the email address
by creating a reply and reading the email address from the reply .TO is the only way i could find it
Code:
cb.settext f & "[" & e & "]"
in my test the sender was not in the address book
the reply part is not required to return the subject
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 19th, 2014, 08:35 PM
#7
Thread Starter
Junior Member
Re: Macro to copy subject line
Originally Posted by westconn1
the senders email address is not included within the email, unless m.senderaddress works for you, it did not for me (maybe different in your version)
m.sendername only returns the name of the sender, not the email address
by creating a reply and reading the email address from the reply .TO is the only way i could find it
Code:
cb.settext f & "[" & e & "]"
in my test the sender was not in the address book
the reply part is not required to return the subject
Thanks westconn1,
Yes I did remove the reply part from subject....
senderemailaddress works for me only for members who are not in my address book....
Code:
Sub getemail()
Dim m As MailItem
Set m = ActiveExplorer.Selection(1)
f = m.SenderEmailAddress
m.Close olDiscard
Set cb = CreateObject("clipbrd.clipboard")
cb.Clear
cb.SetText f & vbNewLine
End Sub
But the challenge if the sender is my contact list it copies like this /O=(companyname)/OU=US/CN=RECIPIENTS/CN=Username_0864.
I was looking if the macro automatically determines the addresses and gives the output according
Members not in my address book - copy emailaddress
Members in my address book - copy just username without their domain.[OR]
members in my address book - Copy just the lastname.
Is it possible?
-
Feb 20th, 2014, 03:53 AM
#8
Re: Macro to copy subject line
as you are in a domain, i can not duplicate your results to test
the method i used above should still work fine
get the .TO email address, from the reply
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|