Hi Trudy,
Thank you for your patience in regards to helping with me. I've actually learned alot through your recomendations and have made the code work for me. I have one last question and hopefully you have the answer for me.
I have the below 2 codes in my work flow which I'm currently using,
1) Automatic Email to be sent when the Status Field Changes
2)Automatic Email to be sent when the Assigned to Field Changes.
Both of these codes seems to work for me when I use them 1 at a time and even displays the message stating that an email has been sent. However, when I have both of the codes in my workflow, I no longer get the "Email Sent" message displayed. What is it that I need to know so that an email gets sent out to designated users with the "Email Sent" messaging popping up when either the "Status" field Changes or the "Assigned To" fields changes
(Status Code) -works only when I dont have the below assigned to code in the same workflow box
Dim strTo
Dim strSubject
Dim strComment
If Bug_Fields("BG_STATUS").IsModified Then
strTO = Bug_Fields("BG_RESPONSIBLE").Value
strSubject = "Defect Status for the defect " & BUG_Fields("BG_BUG_ID").value & " Has Changed to " & BUG_Fields("BG_Status").value
strComment = "Defect Status for the defect " & BUG_Fields("BG_BUG_ID").value & " Has Changed to " & BUG_Fields("BG_Status").value
TDConnection.sendmail strTo, strFrom, strSubject, strComment, NULL, "HTML"
Set TDConnection = nothing
MsgBox "Mail Sent"
End if
(Assigned To Code)
Sub Bug_AfterPost
On Error Resume Next
if Bug_Fields.Field("BG_RESPONSIBLE").IsModified Then
set objBug = TDConnection.BugFactory.Item(Bug_Fields.Field("BG_BUG_ID").Value)
mailTo=Bug_Fields.Field("BG_RESPONSIBLE").Value
mailCC=""
mailopt=1 'TDMAIL_ATTACHMENT
subject="Defecto No. "& Bug_Fields.Field("BG_BUG_ID").Value & " has been reassigned"
comment=Bug_Fields.Field("BG_DEV_COMMENTS").IsNull
objBug.Mail mailTo,mailCC,mailopt,subject,comment
MsgBox "Mail Sent"
end if
On Error GoTo 0
End Sub
Function Bug_CanPost
On Error Resume Next
Bug_CanPost = DefaultRes
On Error GoTo 0
End Function
Sub Bug_FieldChange(FieldName)
On Error Resume Next
On Error GoTo 0
End Sub