J
Junoon
Hi All,
I have created a worksheet which has Transport Drop times in Header Row
(Row 1) from B1 to say Y1 like this:
Name 00:00 00:30 01:00 01:30 02:00.....
-----------------------------------------------------------------
In Column 1, i have a Header Label "Names" for getting names.
I have a .msg template form which has the above voting options.
Employees click on the voting options on the mail form & a voting
response mail is received in my Inbox Folder.
What i am trying to do is to get the Employee Names as well as the
chosen Drop time ( in the form of a "Yes" or "Y") for employees from
Mails sent thru MS Outlook, create a Process folder below Inbox folder
& transfer the processed voting
response mails to that folder.
The code works fine, if the received mails in Outlook are Voting
responses & if they are showing one after the other in th Inbox folder.
BUT, if there are other mails lying in between the voting response
mails, it tends to slow down the code & most of the time, some voting
response mails are not processed.
What i think is that code gets stuck on :
objMail.class=olMail....as it scans for all types of mails & not only
Voting response mails.
Is there a property exclusively for Voting response, so that the code
can scan only for voting response mails & transfer it to processed
folder.
************************************************************************
Sub DropTimes()
Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem, objItem As Object
'Dim objExcel As Excel.Application
Dim objWks As Excel.Worksheet
'Dim objWkb As Excel.Workbook
'Dim objTimeRange As Excel.Range, objRange As Excel.Range
Dim intX As Integer
Dim iRow
'On Error Resume Next
Set objNS = Outlook.Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objWks = ThisWorkbook.Worksheets(ActiveSheet.Name) 'Use default
Sheet1
With objWks
iRow = objWks.Cells(objWks.Rows.Count, 1).End(xlUp).Row + 1
End With
Set objTimeRange = objWks.UsedRange
For Each objItem In objInbox.Items
If objItem.Class = olMail Then ' Here, i guess it should
check only for Voting response mails to fasten the scanning.
Set objMail = objItem
If objMail.VotingResponse <> "" Then
Set objRange =
objTimeRange.Find(objMail.VotingResponse, , , xlWhole)
If Not objRange Is Nothing Then
objWks.Cells(iRow, 1).Value = objMail.SenderName
objWks.Cells(iRow, objRange.Column).Value = "yes"
End If
End If
End If
Set objMail = Nothing
Set objItem = Nothing
Next
Set objRange = Nothing
Set objTimeRange = Nothing
Set objMail = Nothing
Set objWkb = Nothing
Set objWks = Nothing
Set objExcel = Nothing
Set objNS = Nothing
Set objInbox = Nothing
End Sub
***************************************************************
PLEASE HELP ASAP!
I have created a worksheet which has Transport Drop times in Header Row
(Row 1) from B1 to say Y1 like this:
Name 00:00 00:30 01:00 01:30 02:00.....
-----------------------------------------------------------------
In Column 1, i have a Header Label "Names" for getting names.
I have a .msg template form which has the above voting options.
Employees click on the voting options on the mail form & a voting
response mail is received in my Inbox Folder.
What i am trying to do is to get the Employee Names as well as the
chosen Drop time ( in the form of a "Yes" or "Y") for employees from
Mails sent thru MS Outlook, create a Process folder below Inbox folder
& transfer the processed voting
response mails to that folder.
The code works fine, if the received mails in Outlook are Voting
responses & if they are showing one after the other in th Inbox folder.
BUT, if there are other mails lying in between the voting response
mails, it tends to slow down the code & most of the time, some voting
response mails are not processed.
What i think is that code gets stuck on :
objMail.class=olMail....as it scans for all types of mails & not only
Voting response mails.
Is there a property exclusively for Voting response, so that the code
can scan only for voting response mails & transfer it to processed
folder.
************************************************************************
Sub DropTimes()
Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem, objItem As Object
'Dim objExcel As Excel.Application
Dim objWks As Excel.Worksheet
'Dim objWkb As Excel.Workbook
'Dim objTimeRange As Excel.Range, objRange As Excel.Range
Dim intX As Integer
Dim iRow
'On Error Resume Next
Set objNS = Outlook.Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objWks = ThisWorkbook.Worksheets(ActiveSheet.Name) 'Use default
Sheet1
With objWks
iRow = objWks.Cells(objWks.Rows.Count, 1).End(xlUp).Row + 1
End With
Set objTimeRange = objWks.UsedRange
For Each objItem In objInbox.Items
If objItem.Class = olMail Then ' Here, i guess it should
check only for Voting response mails to fasten the scanning.
Set objMail = objItem
If objMail.VotingResponse <> "" Then
Set objRange =
objTimeRange.Find(objMail.VotingResponse, , , xlWhole)
If Not objRange Is Nothing Then
objWks.Cells(iRow, 1).Value = objMail.SenderName
objWks.Cells(iRow, objRange.Column).Value = "yes"
End If
End If
End If
Set objMail = Nothing
Set objItem = Nothing
Next
Set objRange = Nothing
Set objTimeRange = Nothing
Set objMail = Nothing
Set objWkb = Nothing
Set objWks = Nothing
Set objExcel = Nothing
Set objNS = Nothing
Set objInbox = Nothing
End Sub
***************************************************************
PLEASE HELP ASAP!