TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tuman Sahu
1.4k
293
9.4k
SMS & Email does not work in IIS but running in Local Server
Dec 11 2019 12:44 AM
I am making a project for safety. Here i want to sent SMS and Email to end user my SMS and Email function code is bellow. This code is running is Local Server very smoothly and don't know why its not fuctioning in IIS .
Can any one help me what is the actual problem ?
Dim ForSendMessage As String = " ID : " & uc.ID.ToString() & " Is Assign For Unsafe Act/Condition :" & Session("UnsafeMsg").ToString()
Dim strUrl As String = "Using One SMS API Code"
Dim request As WebRequest = HttpWebRequest.Create(strUrl)
Dim response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse)
Dim s As Stream = DirectCast(response.GetResponseStream(), Stream)
Dim readStream As New StreamReader(s)
Dim dataString As String = readStream.ReadToEnd()
lblAssigntoMobile.Text = dataString.ToString
response.Close()
s.Close()
readStream.Close()
Dim st As String = lblAssigntoMobile.Text
Dim subst As String = st.Substring(17, 4)
If subst <> "3001" Then
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "alert", "alert('" & subst.ToString & "')", True)
Else
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "alert", "alert('Message Sent')", True)
End If
Dim mail As MailMessage = New MailMessage()
Const username As String = "myemailid"
Const password As String = "myemailpassword"
Dim smtpclient As SmtpClient = New SmtpClient()
Dim fromaddress As MailAddress = New MailAddress("myemailid")
smtpclient.Host = "smtp.gmail.com"
smtpclient.Port = 587
mail.From = fromaddress
mail.[To].Add(lblAssigntoEmailId.Text)
mail.Subject = ("Hi Test Mail")
mail.IsBodyHtml = True
mail.Body = "<html><head><title>" & HttpUtility.HtmlEncode("Safety Mail") & "</title></head><body style='height:600px'>" & "<p>" + HttpUtility.HtmlEncode(Session("UnsafeMsg").ToString()) & "</p>" & "</body></html>"
smtpclient.EnableSsl = True
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network
smtpclient.Credentials = New System.Net.NetworkCredential(username, password)
smtpclient.Send(mail)
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "alert", "alert('Mail has been sent!!,ID:" & uc.ID & "')", True)
Reply
Answers (
4
)
1
Salman Beg
150
12.1k
613.2k
Dec 11 2019 1:04 AM
Might be you are getting some error after deploy to iis. Thanks
Accepted Answer
1
Rajeesh Menoth
67
27k
2.7m
Dec 11 2019 2:23 AM
Hi,
I think better to log the server error then only we will get know the exact error message. Most of the sms and email related things are working in local comparing to server because it's required additional configurations like smtp, security, etc.
0
Rajeesh Menoth
67
27k
2.7m
Dec 15 2019 9:22 PM
Hi, Welcome , You are using the correct port number ( 587 ) for gmail.
0
Tuman Sahu
1.4k
293
9.4k
Dec 15 2019 9:15 AM
Thanks Rajeesh ji and Salman Beg for respose and i debug the error in iis server and get error. it was related to port issue and fix the bug.
Thanks alot.
Create Scroll Bar
best design for an responsibility system