Tuesday, 5 February 2013

Revised SMTP Code which Takes Arguments

Revised SMTP Code which Takes Arguments 

WebForm_Ref_ID = "AAAGZ001"
Err_Message = "Login Failed"
Filename= "Ayaskant Jena"
Failtype="Login"
Failcause="Incorrect Credentials"
Failwhen= "During Login"
 
Call Mail_Trigger(WebForm_Ref_ID,Err_Message,Filename,Failtype,Failcause,Failwhen)

Public Function Mail_Trigger(WebForm_Ref_ID,Err_Message,Filename,Failtype,Failcause,Failwhen)
  Set objEmail = CreateObject("CDO.Message")
   new_date = split(date,"/")
   new_time = split(time,":")          
  Timestamp = "<"&new_time(0)&new_time(1)& new_time(2)&"_" &new_date(0)&new_date(1)&new_date(2)&">"
  
'This field defines whether to send the message using the local SMTP service drop directory
objEmail.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/sendusing") = 2


'This field defines the smtp server address of optus.com.au
objEmail.Configuration.Fields.Item _

'This field defines the smtp server port of optus.com.au
objEmail.Configuration.Fields.Item _
                                objEmail.Configuration.Fields.Update
objEmail.From = "Project_Thor_Error_Messaging_Service"
objEmail.To = "Ayaskant.Jena;Ravi.tesh"
objEmail.Subject = "Error Messaging Service For Order Reference Number _"&WebForm_Ref_ID
Footer_Details =vbCrlf & vbCrlf &"*********************************************************************************************************" & vbcrlf & "This is an auto-generated email. Please do not reply to this email." & vbcrlf &"*********************************************************************************************************"

Header_Details =  "Hi All," & vbcrLf & vbCrlf & "Please find the error message details below:" & vbcrLf & vbCrlf
objEmail.Textbody = Header_Details &Timestamp&"_"&Filename&"_"&WebForm_Ref_ID&"_"&Failtype&"_"&Failcause&"_"&Failwhen &vbCrlf & Footer_Details

objEmail.Send
End Function

No comments:

Post a Comment