N
News Account
When receiving an email i have some code that builds a function and its
parameters depending on the email address it was sent to. All this
information is in SQL server so i have one loop that builds all the code i
need to process.
My code at the moment looks like this
For Each oMailItem In oInBox.Items
With oMailItem
If oMailItem.UnRead = True Then
strsqlquery = "select * from function_control where
email_address = '" & LCase(oMailItem.To) & "'"
Connect
If GetMainRecordset(strsqlquery, rs1) = True Then
For lThisAttach = 1 To oMailItem.Attachments.Count
oMailItem.Attachments.Item(lThisAttach).SaveAsFile
rs1.Fields("save_location") &
oMailItem.Attachments.Item(lThisAttach).FileName
strquery = "select * from function_process where
function_name = '" & rs1.Fields("function_name") & "'"
If GetMainRecordset(strquery, rs2) = True Then
Do While rs2.EOF = False
callcmd = rs2.Fields("function_to_process")
strquery2 = "select * from
function_parameters where function_name = '" & rs1.Fields("function_name")
& "' and function_to_process = '" &
rs2.Fields("function_to_process") & "'"
If GetMainRecordset(strquery2, rs3) = True
Then
Do While rs3.EOF = False
callcmd = callcmd & " " &
rs3.Fields("function_parameter")
rs3.MoveNext
If rs3.EOF = False Then callcmd =
callcmd & ","
Loop
End If
rs2.MoveNext
Loop
**********This is where i need to execute the Public Sub defined in
Callcmd ***************
End If
If rs1.Fields("save_mail_folder") Is Not Null Then
SaveMail ("'" & rs1.Fields("save_mail_folder") &
"'")
End If
Next
End If
oMailItem.UnRead = False
End If
End With
Next
Set oMailItem = Nothing
Set oInBox = Nothing
Set oNameSpace = Nothing
Set oOutlook = Nothing
Exit Function
Any suggestions would be great - any other info you need please email me
parameters depending on the email address it was sent to. All this
information is in SQL server so i have one loop that builds all the code i
need to process.
My code at the moment looks like this
For Each oMailItem In oInBox.Items
With oMailItem
If oMailItem.UnRead = True Then
strsqlquery = "select * from function_control where
email_address = '" & LCase(oMailItem.To) & "'"
Connect
If GetMainRecordset(strsqlquery, rs1) = True Then
For lThisAttach = 1 To oMailItem.Attachments.Count
oMailItem.Attachments.Item(lThisAttach).SaveAsFile
rs1.Fields("save_location") &
oMailItem.Attachments.Item(lThisAttach).FileName
strquery = "select * from function_process where
function_name = '" & rs1.Fields("function_name") & "'"
If GetMainRecordset(strquery, rs2) = True Then
Do While rs2.EOF = False
callcmd = rs2.Fields("function_to_process")
strquery2 = "select * from
function_parameters where function_name = '" & rs1.Fields("function_name")
& "' and function_to_process = '" &
rs2.Fields("function_to_process") & "'"
If GetMainRecordset(strquery2, rs3) = True
Then
Do While rs3.EOF = False
callcmd = callcmd & " " &
rs3.Fields("function_parameter")
rs3.MoveNext
If rs3.EOF = False Then callcmd =
callcmd & ","
Loop
End If
rs2.MoveNext
Loop
**********This is where i need to execute the Public Sub defined in
Callcmd ***************
End If
If rs1.Fields("save_mail_folder") Is Not Null Then
SaveMail ("'" & rs1.Fields("save_mail_folder") &
"'")
End If
Next
End If
oMailItem.UnRead = False
End If
End With
Next
Set oMailItem = Nothing
Set oInBox = Nothing
Set oNameSpace = Nothing
Set oOutlook = Nothing
Exit Function
Any suggestions would be great - any other info you need please email me