|
-
Jul 20th, 2010, 10:58 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Extract words After -
for example
violation notication - july10
i need only "violation notication"
could you please help me to provide vba code.
thanks
-
Jul 20th, 2010, 11:08 AM
#2
Re: Extract words After -
Don't just copy it 
Understand how it works...
Code:
Sub Sample()
Dim strString As String, MyArray() As String
strString = "violation notication - july10"
MyArray = Split(strString, "-")
MsgBox Trim(MyArray(0))
End Sub
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
-
Jul 20th, 2010, 11:56 AM
#3
Thread Starter
Addicted Member
Re: Extract words After -
Hi kool
i have error mismatch myitem i am trying to find subject in outlook
Public Sub ReadOutlook()
Dim strString As String
Dim MyArray() As String
Dim olNamespace As Outlook.Namespace
Dim olItem As MailItem
Dim i As Integer
Dim b As Integer
Dim olfolder As Outlook.MAPIFolder
Dim lngCol As Long
Dim mypasswrd
Dim olMail As Variant
Set OL = GetObject(, "OUTLOOK.APPLICATION")
Set MAPI = OL.GetNamespace("MAPI")
Set Folder = MAPI.Folders("Inbox")
For Each Myitem In Folder.Items
strString = "Violation Notication - "
MyArray = Split(strString, "-")
If Myitem = MyArray Then
MsgBox (Myitem)
-
Jul 20th, 2010, 12:10 PM
#4
Re: Extract words After -
Do you want to find if the subject has "Violation Notication - "?
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
-
Jul 20th, 2010, 01:45 PM
#5
Thread Starter
Addicted Member
Re: Extract words After -
only find the subject violation notification" not -
-
Jul 20th, 2010, 03:39 PM
#6
Re: Extract words After -
Code:
If Instr( TheStringYouWantToSerachIn, "violation notification") > 0 Then
' it exists
Else
' it doesn't exist
End If
-
Jul 20th, 2010, 04:26 PM
#7
Thread Starter
Addicted Member
Re: Extract words After -
Pradeep
thanks i am captureing information related with the subject "violation notification" to excel
but the subject has '"violation notification - "
i have the code
vb Code:
Public Sub ReadOutlook()
Dim strString As String
Dim MyArray() As String
Dim olNamespace As Outlook.Namespace
Dim olItem As MailItem
Dim i As Integer
Dim b As Integer
Dim olfolder As Outlook.MAPIFolder
Dim lngCol As Long
Dim mypasswrd
Dim olMail As Variant
Set OL = GetObject(, "OUTLOOK.APPLICATION")
Set MAPI = OL.GetNamespace("MAPI")
Set Folder = MAPI.Folders("Inbox")
For Each Myitem In Folder.Items
strString = "Violation Notication - "
MyArray = Split(strString, "-")
If Myitem = trim(MyArray(0) Then
MsgBox (Myitem)
it does not pick up the "Violation Notication"
-
Jul 21st, 2010, 12:21 AM
#8
Re: Extract words After -
Kamakshi: There was a reason why I asked the question in post 4.
You don't need to use split() to check for the existence of a word(s) in a string. You need to use Instr() as Pradeep suggested. I gave you the split() option based on the query in post 1
Let me give you an example.
Code:
#
Set OL = GetObject(, "OUTLOOK.APPLICATION")
Now are you automating Outlook? From Excel or or from Word?
What do you exactly want to do if you find an email with the subject that you want?
Don't paste any code yet. Just give me a simple 'flow' of what you want
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
-
Jul 21st, 2010, 07:11 AM
#9
Thread Starter
Addicted Member
Re: Extract words After -
i am automating outlook to excel filtering the only in the subject 'violence notification corresponding sendername received time.
-
Jul 21st, 2010, 07:28 AM
#10
Re: Extract words After -
Here is the most simple example I can give you 
Note: Please set a reference to Outlook Object Library by clicking on the menu Tools--> References and selecting the Microsoft Outlook Object Library.
Code:
'~~> Set reference to Outlook Object Library by clicking on
'~~> Tools-->References and selecting the Microsoft Outlook Object Library
Sub CheckMailInInbox()
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
For Each olMail In Fldr.Items
If InStr(olMail.Subject, "Violation Notication - ") > 0 Then
'~~> I am displaying the entire subject
MsgBox olMail.Subject
'~~> Your code here to do whatever you want
End If
Next olMail
Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub
Edit:
BTW olMail.ReceivedTime will give you the received time of the email and olMail.SenderName will give you the sender's name.
Last edited by Siddharth Rout; Jul 21st, 2010 at 07:35 AM.
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
-
Jul 21st, 2010, 08:06 AM
#11
Thread Starter
Addicted Member
Re: [RESOLVED] Extract words After -
thanks kool it is resolved.
-
Jul 21st, 2010, 08:06 AM
#12
Re: [RESOLVED] Extract words After -
Glad to be of help
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
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
|