Thank you. As always internet provides so complicated solutions to problems people made for no reason and you present impossible things in a way everyone can understand and apply. Best channel of all time.
That is an incredible video, it helps me a lot!.. i was searching for this information in youtube channels from Mexico, but i could not find it anywhere. Thank you very much my friend!, greetings from Mexico.
Wow, Andrew, thank you for posting a video after aeons, I started learning VBA in 2017 and since then I have considered you as my mentor. Would you be posting more videos in future? Something must be wrong with me but your videos are more entertaining than Netflix.
@@WiseOwlTutorials Hi, just in general for example recording , some tips and shortcuts to improve efficiency ,saving the Marcos to be used with multi-spreadsheet. thanks
First of all Very big thanks for this Video. And please make a video on How to do same when we have more than One Email A/C configured and we want to copy emails from a particular Email id. Thanks
Hi Selva! You can apply the Reply or Forward methods to a MailItem object. Both methods return a MailItem object which you can then manipulate in the same way as a new email. To get a reference to an email that you want to forward or reply to you can use the Find or Restrict methods. We have videos on those topics in this playlist th-cam.com/play/PLNIs-AWhQzcleylKSN4MS-tJloReq0XcK.html I hope it helps!
@@WiseOwlTutorials Thank you for the reply. The videos looks useful. as I am new to excel VBA it will be awesome if you happen to have video which shows a sample of how to do the actual excel VBA code for either replying and forwarding of emails...I think other viewers would be interested to know too...thank you for your consideration. Have a nice day
Hi, thanks for sharing this technique. My loop stops at calendar invite in my outlook inbox and whole process stops. How to skip/ avoid calendar invite while doing loop and pushed the process to complete till last email?
Hey, I had some error in getting the recipient mail from outlook. I am getting my name sometimes and my email-ID sometimes. Could you help me with this. Thanks 😊
Hi Andrew I neely copied your code word for word and la deuxieme part ne fonctione pas at the seting of the word doctument with the gettinginspector kind regards Kherrat
@@WiseOwlTutorials Thank you so much for the quick reply! I have reviewed the ADO videos several times and I can create ADO connections confidently. I will review the tutorial for the Outlook folders and sub-folders. The wise owl videos are truly some of the best for working with VBA especially since you have covered most of the topics in depth. I can honestly say that after watching the wise owl tutorials my VBA skills have improved tremendously and I have applied what I have learned in the business world. Your work is greatly appreciated!
Hi there! I don't have any experience working with Gmail I'm afraid. I know that Google provide an API for working with Gmail but I don't know how you'd integrate that with VBA.
Would it be also possible to loop through Sub-Subfolders? Yes, the sub of a sub. No typo! I use OL as kind of Project Management tool though it's hard to overlook everything meanwhile. To have it summarized in one Excel-Sheet would help a lot. Some material available how to loop through inbox and subfolders but nothing further going so I guess it's impossible.
Hi Andrew, I hope you are doing well, I have one question to you, can I move all the mails (mails that category is blank) from a folder to another folder at once like copy and paste not through loop, move bulk mails at once, is this possible? if yes? please help me. Like if we do manually then will go to that folder then apply filter the mails then select those filtered mails and drage those mails to another folder, at once we moved all the mails to difference folder. Please take good care of yourself and your family. Thanks Kashif
Hi Kashif! I don't know of a way to do what you're asking. The Restrict method returns a collection of filtered Items. But the Items object doesn't have a move method so you'd still need to loop through the returned items collection and apply the move method to each email separately. I'd be interested to hear if you discover a way to move multiple items at once!
Hi Andrew, I have a list of email address and each of them has their own assistants in their outlook contact details. How can I get the name of that assistant then copy it into a worksheet? I am having trouble referencing with Namespace. Thanks.
Hi Dan! I'm not familiar with assistants in Outlook (I guess I'm not important enough to have one!). Where do you have this list of email addresses stored and where are you seeing the assistant names in the contact details? All I've got is the Microsoft Docs reference to the AssistantName property docs.microsoft.com/en-us/office/vba/api/outlook.exchangeuser.assistantname And the Docs reference to the ExchangeUser object (which AssistantName is a property of) docs.microsoft.com/en-us/office/vba/api/outlook.exchangeuser
Hi Rodrigo! You can use a variable to capture a reference to the Items of a folder, then apply the Sort method to the variable and then use the variable in the For Each loop like so: Dim InboxItems As Outlook.Items
Hi Andrew, I hope you are doing good and staying safe, I have one question in outlook, in a folder there are multiple mails and in this folder have many mails that have the subject "TestMail_1" and my requirement is that if the mail's subject is "TestMail_1" then I want to move this mail to another folder, and for this I am applying loop in this folder, this loop is not moving all the mails that have the subject "TestMail_1" it is only moving some of the mails not all, I don't know why but it is skipping some mails. For Testing purpose suppose in the source folder have 9 mails with following subject. 1st mail Subject: TestMail_1 2nd mail Subject: TestMail_5 3rd mail Subject: TestMail_1 4th mail Subject: TestMail_4 5th mail Subject: TestMail_2 6th mail Subject: TestMail_1 7th mail Subject: TestMail_1 8th mail Subject: TestMail_1 9th mail Subject: TestMail_1 Code: Set outFolderSource=namespace.Folders("emailaddress").folders("SourceFolder") Set outFolderDestination=namespace.Folders("emailaddress").folders("DestinationFolder") For each outMail in outFolderSource.Items If outMail.Class=olMail Then If Instr(outMail.Subject, "TestMail_1")>0 then outMail.Move outFolderDestination End if End if Next outMail My kind request to you that please help me to resolve this issue. Thanks Kashif
Hi Kashif, the code looks good! I'm sorry I don't know why it would skip items. Does it skip items if you simply try to Debug.Print the email subject rather than move the email? Does it behave differently when you step through the procedure with F8 rather than running it with F5?
@@WiseOwlTutorials Hi thanks for the reply, yes sometimes it also skips the mail when I debug the MessegaClass property, so I think it will also do the same with Subject. Thanks Kashif
Is there some way to copy only part of the body from email ? Some emails may cause out of memory error ;D I amsking because I need to check for a specific combinations of text in subject and then if it fails in body text. If email has a lot of words it may cause crashes ;P
Hi Enrike! You could use the GetInspector property of the MailItem and use that to get a reference to a Word document. You can then use Word VBA techniques to find and return any text you like from the email. Here's some basic information on the GetInspector property docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.getinspector Of course you'll need to adapt it to refer to your existing emails and then work out how to find text using Word VBA docs.microsoft.com/en-us/office/vba/word/concepts/customizing-word/finding-and-replacing-text-or-formatting I hope that points you in the right direction!
@@WiseOwlTutorials I didn't see that notification . Nice TH-cam! Thank you very much. I just got an idea regarding my macro and run into it without watching rest of your tutorials. I saw them all several times but my memory is questionable. I still need to adapt that hint from you. Just for information that someone may use. I got quite a job to do to get some lazy time at work. I am more excel functions guy than vba but Thanks to you I improved like crazy. So I use exchange account in Outlook and Excel doesn't see that account the way you pointed out but I still have access to emails. The issue will be that mail sent from other account will not be visible in the Sent Items of the exchange account. I propably will forward the mail I want and then manually move Items I sent to the archive. Although I am not there yet. Internet said that even if you send an email onbehalf than it still won't be in that exchange account mail box . That email body is troublesome because I use excel functions so I paste all data into excel cell and then convert it .Yet if mail contains several answers within and pictures than it is hard to loop through such mail and paste all data into cell. It takes a lot of time. Pictures might be the reason. Pictures do not paste into cell but coping process takes forever. I just type activecell.value = mi.body heheh Signature of each person belongs to body so it is annoying. Right now I just used instr and if there is HTTPS than the text ends but I know some mails have several answers ;P Right now the biggest issue I just solved Today was to make a sub that gets string of text made of 14 digits directly from email's subject or the body and saves it as variable. Using Excel functions it is quite simple and quite not to do. In Excel if I use function mid (activecell.value,( search (" ????????",text),lenght ) + 0 I can check if text excel found is number but than if number had zeros at the beginning they all disappear so I need to add them ;P sometimes clients type spaces between digits so I check such possibility with search "?? ???? ??" nevertheless I somehow did that using about 20 variants of text format ?????? And another sub using counter and checking if the next counter (character)in body isnumeric and if so then add another character...at the end it saves only variable with all digit characters. I don't know how I did IT but it's Thanks to you and your videos. Still I will have to convert Excel functions into vba functions to make it work faster but I don't know how yet. Still I feel great ;D Making such macros is really challenging and fun. I would really like to support the channel but I don't have credit card. Please add some bank account number on your official website ;)
@@WiseOwlTutorials Hi. You always point my brain in the right direction ;) I am going to make that macro within 30 days ;P and then no more work at work ;) to some extent ;D
@@enrikekasijas705 Hi Enrike! It sounds like you're having lots of fun solving problems with VBA and I'm happy to hear that the videos have helped you! Good luck with the remaining challenges and I hope you continue to enjoy it!
Hi Andrew, Thank you thank you thank you million times thank you so much for this lovely tutorial, God bless you. I have couple of problems that I am describing below. Problem 1:- Below is the code for attachments, we talked in previous comment, it is also counting those mails that does not have any attachments but have embedded images in the mail body. Code:- Sub Practice_Outlook() Dim objOutlook As Outlook.Application Dim objNamespace As Outlook.Namespace Dim objFolder As Outlook.Folder Dim objItems As Outlook.Items Dim objItem As Outlook.MailItem Dim intCount As Integer Dim intLoop As Integer Dim intAttachmentMailCount As Integer
Set objOutlook = New Outlook.Application Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox) Set objItems = objFolder.Items
'Check if the refrencing mail is not a mail then set the reference 'If objItems(intLoop).Class olMeetingRequest Then 'For checking if the referencing mail is a mail then set the reference 'if objitems(intloop).class=olmail then If objItems(intLoop).Class olMeetingRequest Then Set objItem = objItems(intLoop)
If objItem.Attachments.count > 0 Then Debug.Print objItem.Attachments(1).DisplayName Debug.Print "There is an attachments in the mail." & vbCrLf & _ "Subject: " & objItem.Subject & vbCrLf & _ "date:- " & objItem.CreationTime
intAttachmentMailCount = intAttachmentMailCount + 1 End If End If Next intLoop Debug.Print intAttachmentMailCount End Sub Problem 2:- In a sheet and in a column A, I have some email addresses and in column B I want to fetch their Reporting Manager Name, the code below is working fine, however whenever it is fetching the Manage Name it displays a security message to ALLOW and DENY, and it is tiresome to click each and every time to fetch the Manager Name, say I have around 100 email address then I will have to click 100 times, please advice me how can I overcome this problem. Code:- Sub GetReportingManagerNameFromAddressBook_Outlook() Dim colAL As Outlook.AddressLists Dim oAL As Outlook.AddressList Dim colAE As Outlook.AddressEntries Dim oAE As Outlook.AddressEntry Dim oExUser As Outlook.ExchangeUser Dim ws As Worksheet Dim r As Range, rEach As Range Dim lLastRow As Long
With Sheet4 lLastRow = .Cells(Rows.Count, "A").End(xlUp).Row Set r = .Range(.Cells(2, "A"), .Cells(lLastRow, "A")) End With
Set colAL = Outlook.Application.Session.AddressLists For Each rEach In r For Each oAL In colAL
If oAL.AddressListType = olExchangeGlobalAddressList Then Set colAE = oAL.AddressEntries For Each oAE In colAE If oAE.AddressEntryUserType = olExchangeUserAddressEntry Then Set oExUser = oAE.GetExchangeUser If oExUser.PrimarySmtpAddress = rEach.Value Then
rEach.Offset(0, 1).Value = oExUser.GetExchangeUserManager Exit For End If End If Next oAE End If Next oAL Next rEach
dude cant you track the guy (who threatened to harm you ) by his email ID and report him to the police .....also awesome channel you put out great content ......
Thank you. As always internet provides so complicated solutions to problems people made for no reason and you present impossible things in a way everyone can understand and apply.
Best channel of all time.
Thank you Enrike!
That is an incredible video, it helps me a lot!.. i was searching for this information in youtube channels from Mexico, but i could not find it anywhere. Thank you very much my friend!, greetings from Mexico.
Ola! You're very welcome, I'm happy to hear that the videos have helped you. Thank you so much for the kind comments and for watching!
Great video, I really like the pace and fluidity of your presentation.
I have to say - Andrew, you are brilliant. Thank you!
thank you for your videos are a treasure
Thanks so much, Kherrat!
Wow, Andrew, thank you for posting a video after aeons, I started learning VBA in 2017 and since then I have considered you as my mentor. Would you be posting more videos in future? Something must be wrong with me but your videos are more entertaining than Netflix.
Thank you for the nice video! Could I check if you have video on how to reply or forward emails using excel VBA? Thank you much for your help time
This was extremely helpful. Thank you for this video!
You're very welcome Jj! Happy to hear you found it useful and thanks for watching!
Welcome back Andrew ! ✨✨✨
Very useful tutorial, thank you.
You're very welcome Rafael! Thank you for watching and for taking the time to leave a comment!
Over the moon, you back again
@@WiseOwlTutorials I was wandering if you have done some videos on recording macros? many thanks
@@WiseOwlTutorials Hi, just in general for example recording , some tips and shortcuts to improve efficiency ,saving the Marcos to be used with multi-spreadsheet. thanks
First of all Very big thanks for this Video.
And please make a video on How to do same when we have more than One Email A/C configured and we want to copy emails from a particular Email id.
Thanks
You are back 😍
@@WiseOwlTutorials where have you been
Excellent tutorial! Can you please share code to change the default folder cos I have multiple mailboxes setup in my outlook. Thanks!
Thanks for the info! Would it be possible to insert an embedded outlook email as an object using vba?
Hi Jordan! Yes, check out the Add method of the OLEObjects collection learn.microsoft.com/en-us/office/vba/api/excel.oleobjects.add
I hope it helps!
YOU ARE WONDERFUL THANK YOU
Thank you for the useful videos. Could I check how to reply and forward emails using excel vba? Do you have a video for that? Thank you
Hi Selva! You can apply the Reply or Forward methods to a MailItem object. Both methods return a MailItem object which you can then manipulate in the same way as a new email. To get a reference to an email that you want to forward or reply to you can use the Find or Restrict methods. We have videos on those topics in this playlist th-cam.com/play/PLNIs-AWhQzcleylKSN4MS-tJloReq0XcK.html
I hope it helps!
@@WiseOwlTutorials Thank you for the reply. The videos looks useful. as I am new to excel VBA it will be awesome if you happen to have video which shows a sample of how to do the actual excel VBA code for either replying and forwarding of emails...I think other viewers would be interested to know too...thank you for your consideration. Have a nice day
@@selvan1264 Thanks Selva, I'll put the topic on my list!
@@WiseOwlTutorials Thank you, will be nice to see the video if there is...have a nice day
Made my day
Thank you
Hi, thanks for sharing this technique. My loop stops at calendar invite in my outlook inbox and whole process stops. How to skip/ avoid calendar invite while doing loop and pushed the process to complete till last email?
Hello! Great tutorial!! What if I wanted to reference it to a PST folder? Is that also possible?
Again thank you so much sir g 🙏🙏🙏🇮🇳 you r awesome sir awesome....
Can we create bookmarks in mailbody and use for hyperlink with VBA?
Thank you
You're welcome Rahul, thanks for watching!
Hey, I had some error in getting the recipient mail from outlook. I am getting my name sometimes and my email-ID sometimes. Could you help me with this. Thanks 😊
Hi Andrew
I neely copied your code word for word and la deuxieme part ne fonctione pas at the seting of the word doctument with the gettinginspector
kind regards Kherrat
Great video. I would like to copy the e-mails to a Microsoft Access form instead of a worksheet. Also what if the inbox has sub folders?
@@WiseOwlTutorials Thank you so much for the quick reply! I have reviewed the ADO videos several times and I can create ADO connections confidently. I will review the tutorial for the Outlook folders and sub-folders. The wise owl videos are truly some of the best for working with VBA especially since you have covered most of the topics in depth. I can honestly say that after watching the wise owl tutorials my VBA skills have improved tremendously and I have applied what I have learned in the business world. Your work is greatly appreciated!
Can we also extract gmail email subject line and sender email ids?
Hi there! I don't have any experience working with Gmail I'm afraid. I know that Google provide an API for working with Gmail but I don't know how you'd integrate that with VBA.
Thank you for the video! I cant download the file in website :(
Hi Alessandro, apologies, this problem should now be resolved!
@@WiseOwlTutorials dont worry, u taught me a lot, thank you 😀
Would it be also possible to loop through Sub-Subfolders? Yes, the sub of a sub. No typo! I use OL as kind of Project Management tool though it's hard to overlook everything meanwhile. To have it summarized in one Excel-Sheet would help a lot. Some material available how to loop through inbox and subfolders but nothing further going so I guess it's
impossible.
@@WiseOwlTutorials Wow! Didn' t expect that! Thank u very much Sir!
Hi Andrew,
I hope you are doing well, I have one question to you, can I move all the mails (mails that category is blank) from a folder to another folder at once like copy and paste not through loop, move bulk mails at once, is this possible? if yes? please help me.
Like if we do manually then will go to that folder then apply filter the mails then select those filtered mails and drage those mails to another folder, at once we moved all the mails to difference folder.
Please take good care of yourself and your family.
Thanks
Kashif
Hi Kashif!
I don't know of a way to do what you're asking. The Restrict method returns a collection of filtered Items. But the Items object doesn't have a move method so you'd still need to loop through the returned items collection and apply the move method to each email separately.
I'd be interested to hear if you discover a way to move multiple items at once!
Andrew! thanks for the reply, sure, I am still searching the answer and I will let you know if I find any answers.
Thanks
Kashif
Great Sir.
Hi Andrew, I have a list of email address and each of them has their own assistants in their outlook contact details. How can I get the name of that assistant then copy it into a worksheet? I am having trouble referencing with Namespace.
Thanks.
Hi Dan! I'm not familiar with assistants in Outlook (I guess I'm not important enough to have one!). Where do you have this list of email addresses stored and where are you seeing the assistant names in the contact details? All I've got is the Microsoft Docs reference to the AssistantName property
docs.microsoft.com/en-us/office/vba/api/outlook.exchangeuser.assistantname
And the Docs reference to the ExchangeUser object (which AssistantName is a property of) docs.microsoft.com/en-us/office/vba/api/outlook.exchangeuser
Thank u...
You're welcome, thanks for watching!
How to print the data in cells after the first row rather than the first row itself ?
Hi Allen, you can set the value of the n variable to 1 before beginning the For Each loop. I hope that helps!
Thanks with ears still attached.
Hi, the for each can be traversed in reverse ???
thanks.
Hi Rodrigo! You can use a variable to capture a reference to the Items of a folder, then apply the Sort method to the variable and then use the variable in the For Each loop like so:
Dim InboxItems As Outlook.Items
Set InboxItems = fol.Items
InboxItems.Sort "[ReceivedTime]", True
For Each i In InboxItems
I hope that helps!
@@WiseOwlTutorials Thank you. Yes it worked for me.
@@rodrigoordenes4858 Excellent Rodrigo, thank you for letting us know!
thks, a lot. Regards...
You're very welcome, thank you for watching!
Hi Andrew, I hope you are doing good and staying safe, I have one question in outlook, in a folder there are multiple mails and in this folder have many mails that have the subject "TestMail_1" and my requirement is that if the mail's subject is "TestMail_1" then I want to move this mail to another folder, and for this I am applying loop in this folder, this loop is not moving all the mails that have the subject "TestMail_1" it is only moving some of the mails not all, I don't know why but it is skipping some mails.
For Testing purpose suppose in the source folder have 9 mails with following subject.
1st mail Subject: TestMail_1
2nd mail Subject: TestMail_5
3rd mail Subject: TestMail_1
4th mail Subject: TestMail_4
5th mail Subject: TestMail_2
6th mail Subject: TestMail_1
7th mail Subject: TestMail_1
8th mail Subject: TestMail_1
9th mail Subject: TestMail_1
Code:
Set outFolderSource=namespace.Folders("emailaddress").folders("SourceFolder")
Set outFolderDestination=namespace.Folders("emailaddress").folders("DestinationFolder")
For each outMail in outFolderSource.Items
If outMail.Class=olMail Then
If Instr(outMail.Subject, "TestMail_1")>0 then
outMail.Move outFolderDestination
End if
End if
Next outMail
My kind request to you that please help me to resolve this issue.
Thanks
Kashif
Hi Kashif, the code looks good! I'm sorry I don't know why it would skip items. Does it skip items if you simply try to Debug.Print the email subject rather than move the email? Does it behave differently when you step through the procedure with F8 rather than running it with F5?
@@WiseOwlTutorials Hi thanks for the reply, yes sometimes it also skips the mail when I debug the MessegaClass property, so I think it will also do the same with Subject.
Thanks
Kashif
Is there some way to copy only part of the body from email ? Some emails may cause out of memory error ;D I amsking because I need to check for a specific combinations of text in subject and then if it fails in body text. If email has a lot of words it may cause crashes ;P
Hi Enrike! You could use the GetInspector property of the MailItem and use that to get a reference to a Word document. You can then use Word VBA techniques to find and return any text you like from the email. Here's some basic information on the GetInspector property
docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.getinspector
Of course you'll need to adapt it to refer to your existing emails and then work out how to find text using Word VBA docs.microsoft.com/en-us/office/vba/word/concepts/customizing-word/finding-and-replacing-text-or-formatting
I hope that points you in the right direction!
@@WiseOwlTutorials I didn't see that notification . Nice TH-cam! Thank you very much. I just got an idea regarding my macro and run into it without watching rest of your tutorials. I saw them all several times but my memory is questionable. I still need to adapt that hint from you. Just for information that someone may use. I got quite a job to do to get some lazy time at work. I am more excel functions guy than vba but Thanks to you I improved like crazy. So I use exchange account in Outlook and Excel doesn't see that account the way you pointed out but I still have access to emails. The issue will be that mail sent from other account will not be visible in the Sent Items of the exchange account. I propably will forward the mail I want and then manually move Items I sent to the archive. Although I am not there yet. Internet said that even if you send an email onbehalf than it still won't be in that exchange account mail box . That email body is troublesome because I use excel functions so I paste all data into excel cell and then convert it .Yet if mail contains several answers within and pictures than it is hard to loop through such mail and paste all data into cell. It takes a lot of time. Pictures might be the reason. Pictures do not paste into cell but coping process takes forever. I just type activecell.value = mi.body heheh Signature of each person belongs to body so it is annoying. Right now I just used instr and if there is HTTPS than the text ends but I know some mails have several answers ;P Right now the biggest issue I just solved Today was to make a sub that gets string of text made of 14 digits directly from email's subject or the body and saves it as variable. Using Excel functions it is quite simple and quite not to do. In Excel if I use function mid (activecell.value,( search (" ????????",text),lenght ) + 0 I can check if text excel found is number but than if number had zeros at the beginning they all disappear so I need to add them ;P sometimes clients type spaces between digits so I check such possibility with search "?? ???? ??" nevertheless I somehow did that using about 20 variants of text format ?????? And another sub using counter and checking if the next counter (character)in body isnumeric and if so then add another character...at the end it saves only variable with all digit characters. I don't know how I did IT but it's Thanks to you and your videos. Still I will have to convert Excel functions into vba functions to make it work faster but I don't know how yet. Still I feel great ;D
Making such macros is really challenging and fun. I would really like to support the channel but I don't have credit card. Please add some bank account number on your official website ;)
@@WiseOwlTutorials Hi. You always point my brain in the right direction ;) I am going to make that macro within 30 days ;P and then no more work at work ;) to some extent ;D
@@enrikekasijas705 Hi Enrike! It sounds like you're having lots of fun solving problems with VBA and I'm happy to hear that the videos have helped you! Good luck with the remaining challenges and I hope you continue to enjoy it!
@@enrikekasijas705 😀 that's the dream!
thanks
Hi Andrew,
Thank you thank you thank you million times thank you so much for this lovely tutorial, God bless you.
I have couple of problems that I am describing below.
Problem 1:-
Below is the code for attachments, we talked in previous comment, it is also counting those mails that does not have any attachments but have embedded images in the mail body.
Code:-
Sub Practice_Outlook()
Dim objOutlook As Outlook.Application
Dim objNamespace As Outlook.Namespace
Dim objFolder As Outlook.Folder
Dim objItems As Outlook.Items
Dim objItem As Outlook.MailItem
Dim intCount As Integer
Dim intLoop As Integer
Dim intAttachmentMailCount As Integer
Set objOutlook = New Outlook.Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set objItems = objFolder.Items
intCount = objItems.count
intAttachmentMailCount = 0
For intLoop = 1 To intCount
'Check if the refrencing mail is not a mail then set the reference
'If objItems(intLoop).Class olMeetingRequest Then
'For checking if the referencing mail is a mail then set the reference
'if objitems(intloop).class=olmail then
If objItems(intLoop).Class olMeetingRequest Then
Set objItem = objItems(intLoop)
If objItem.Attachments.count > 0 Then
Debug.Print objItem.Attachments(1).DisplayName
Debug.Print "There is an attachments in the mail." & vbCrLf & _
"Subject: " & objItem.Subject & vbCrLf & _
"date:- " & objItem.CreationTime
intAttachmentMailCount = intAttachmentMailCount + 1
End If
End If
Next intLoop
Debug.Print intAttachmentMailCount
End Sub
Problem 2:-
In a sheet and in a column A, I have some email addresses and in column B I want to fetch their Reporting Manager Name, the code below is working fine, however whenever it is fetching the Manage Name it displays a security message to ALLOW and DENY, and it is tiresome to click each and every time to fetch the Manager Name, say I have around 100 email address then I will have to click 100 times, please advice me how can I overcome this problem.
Code:-
Sub GetReportingManagerNameFromAddressBook_Outlook()
Dim colAL As Outlook.AddressLists
Dim oAL As Outlook.AddressList
Dim colAE As Outlook.AddressEntries
Dim oAE As Outlook.AddressEntry
Dim oExUser As Outlook.ExchangeUser
Dim ws As Worksheet
Dim r As Range, rEach As Range
Dim lLastRow As Long
With Sheet4
lLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set r = .Range(.Cells(2, "A"), .Cells(lLastRow, "A"))
End With
Set colAL = Outlook.Application.Session.AddressLists
For Each rEach In r
For Each oAL In colAL
If oAL.AddressListType = olExchangeGlobalAddressList Then
Set colAE = oAL.AddressEntries
For Each oAE In colAE
If oAE.AddressEntryUserType = olExchangeUserAddressEntry Then
Set oExUser = oAE.GetExchangeUser
If oExUser.PrimarySmtpAddress = rEach.Value Then
rEach.Offset(0, 1).Value = oExUser.GetExchangeUserManager
Exit For
End If
End If
Next oAE
End If
Next oAL
Next rEach
MsgBox "Done"
End Sub
Thanks once again.
Thanks
Kashif
Hi @Kashif
Maybe I'am wrong but did you try to turn off the "DisplayAlerts" ?
like :
Application.DisplayAlerts = False
Yes I tried however it is still not working
dude cant you track the guy (who threatened to harm you ) by his email ID and report him to the police .....also awesome channel you put out great content ......
Thanks Oscar! Happy to hear you're enjoying the videos! And thanks for your concern but I don't think the threat was a serious one!
Ears are highly overrated ;-)