I am trying to explore the email task in SSIS. I have a task which has only the email task. When I run its not throwing any error instead it says successfuly run but I am not recieving mail. I dont know how to trace this, could someone help me on this?
I'm sending email by sript component because in the company I cant send via SMTP...
Do you want to try send by script?
Regards!
|||Yes, I can make a try on it. Please send the script. Thanks.|||
Dhanasu wrote: |
|
I am trying to explore the email task in SSIS. I have a task which has only the email task. When I run its not throwing any error instead it says successfuly run but I am not recieving mail. I dont know how to trace this, could someone help me on this? |
Perhaps it's getting caught up in a spam filter. Or the SMTP server isn't letting that e-mail through. Have you talked to the server admin?|||
here you have...
Code Snippet
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net
Imports System.IO
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
Dim strServer As String = "mail.Grupo.com"
Dim strSender As String = "pedro"
Dim strTo As String = "mswail@.mail.com"
Dim strSenderAlias As String = "Pedro"
Dim strSubject As String = "SUCESS Import CLiq - " & Today()
Dim strBody As String = "OK"
Dim sUri As String
sUri = "http://" + strServer + "/Exchange/" + strSenderAlias
sUri = sUri + "/%23%23DavMailSubmissionURI%23%23/"
Dim myUri As System.Uri = New System.Uri(sUri)
Dim HttpWRequest As HttpWebRequest = CType(WebRequest.Create(myUri), HttpWebRequest)
Dim sQuery As String
sQuery = "To: " & strTo & vbNewLine & _
"Subject: " & strSubject & vbNewLine & _
"Date: " & Date.Now & vbNewLine & _
"X-Mailer: My DAV mailer" & vbNewLine & _
"MIME-Version: 1.0" & vbNewLine & _
"Content-Type: text/plain" & vbNewLine & _
"Charset = ""iso-8859-1""" & vbNewLine & _
"Content-Transfer-Encoding: 7bit" & vbNewLine & vbNewLine & _
strBody
Dim myCred As NetworkCredential = New NetworkCredential("GRUPOCGD\rhs0002", "275007")
Dim myCredentialCache As CredentialCache = New CredentialCache()
myCredentialCache.Add(myUri, "Basic", myCred)
HttpWRequest.Credentials = myCredentialCache
HttpWRequest.Headers.Set("Translate", "f")
HttpWRequest.ContentType = "message/rfc822"
HttpWRequest.ContentLength = sQuery.Length
HttpWRequest.Timeout = 300000
HttpWRequest.Method = "PUT"
Dim ByteQuery As Byte() = System.Text.Encoding.ASCII.GetBytes(sQuery)
HttpWRequest.ContentLength = ByteQuery.Length
Dim QueryStream As Stream = HttpWRequest.GetRequestStream()
QueryStream.Write(ByteQuery, 0, ByteQuery.Length)
QueryStream.Close()
Dim HttpWResponse As HttpWebResponse = CType(HttpWRequest.GetResponse(), HttpWebResponse)
Dim iStatCode As Integer = CType(HttpWResponse.StatusCode, Integer)
Dim sStatus As String = iStatCode.ToString()
myCred = Nothing
myCredentialCache = Nothing
HttpWRequest = Nothing
HttpWResponse = Nothing
QueryStream = Nothing
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
|||I am wiating for the reply from the admin. The from and to addresses are mine, so there are no possibility for Spam filter. If the SMTP is in error I hope I should get error message !!!|||
The SMTP i am trying is incorrect. I used the correct SMTP and it worked.
Question: Why does the SSIS not throwing error on incorrect SMTP.
|||
Dhanasu wrote: |
|
The SMTP i am trying is incorrect. I used the correct SMTP and it worked. Question: Why does the SSIS not throwing error on incorrect SMTP. |
You mean you used the wrong server?
|||Yes, i was using wrong server.|||
Dhanasu wrote: |
|
Yes, i was using wrong server. |
But it must've been a valid SMTP server -- one that accepts connections and such. So technically there wasn't an error.|||
Phil Brammer wrote: |
|
Dhanasu wrote: | | Yes, i was using wrong server. | |
But it must've been a valid SMTP server -- one that accepts connections and such. So technically there wasn't an error.
If the SMTP server is invalid, because it will not be able to find that server at all, it wont throw any error for opening the connection I agree. But since its not able to find the server specified in the connection manager, it should throw the error for this right?
Thanks
|||
Karunakaran wrote: |
|
Phil Brammer wrote: | | Dhanasu wrote: | | Yes, i was using wrong server. | | But it must've been a valid SMTP server -- one that accepts connections and such. So technically there wasn't an error.
|
If the SMTP server is invalid, because it will not be able to find that server at all, it wont throw any error for opening the connection I agree. But since its not able to find the server specified in the connection manager, it should throw the error for this right?
Thanks
When I set it up to point to a server that doesn't exist, I get an error message: "[Send Mail Task] Error: An error occurred with the following error message: "Failure sending mail.". "
So if the OP above didn't get an error message and the task succeeded, then it must've been a valid SMTP server, just not the correct one.|||
An added question: Since the mail task is directly bind with the SMTP I can send emails from anonymous email as the "from email id". Is this an issue in my server configuration or in SSIS "send task"?