ASP.NET change image path to https - asp.net

I have code which produces an image path. The issue is my site has been changed to https and the image no longer show because the image path is http. Can anyone suggest how I change the code below to https?
If routes.ContainsKey(m_id) Then
Dim m_uri As Uri = CurrentNode.Uri
Dim m_builder As New UriBuilder (m_uri.Scheme,m_uri.Host)
m_builder.Path=String.Format("/resources/image/gritroutes/gritmaps/{0}.jpg",m_id)
TitleBar.Text = Property_title + " for " + routes.item(m_id) + " - Council"
phGritPic.Text = String.Format("<img src='{0}' alt='grit route' style='max-width: 530px;' class='auto' />",m_builder.ToString)
phGrittingKeyText.Visible = True
End If

You can change m_url.Scheme to m_uri.SchemeHttps
If routes.ContainsKey(m_id) Then
Dim m_uri As Uri = CurrentNode.Uri
Dim m_builder As New UriBuilder (m_uri.SchemeHttps,m_uri.Host)
m_builder.Path=String.Format("/resources/image/gritroutes/gritmaps/{0}.jpg",m_id)
TitleBar.Text = Property_title + " for " + routes.item(m_id) + " - Council"
phGritPic.Text = String.Format("<img src='{0}' alt='grit route' style='max-width: 530px;' class='auto' />",m_builder.ToString)
phGrittingKeyText.Visible = True
End If

Related

Attachment not sent from Server while Locally work's perfectly

Actually i'm trying to send via ASPX using VB.NET as language a mail with attachment that user put in the form via FileUpload which i save to a folder.
All works fine the file is saved and the mail is sent with attachment when i run the site Locally but on the server if i attach something the file is just saved but the email is not sent.
Here is the code where i add the attachment to the mail.
Dim Message As New MailMessage()
Message.To.Add(New MailAddress(reparto))
Message.Subject = oggetto
Message.IsBodyHtml = True
Message.Body =
"<p><h3> " + prodotto + " </h3><br /> " +
"Richiesta di assistenza per il seguente motivo: " + descr +
" <br /> " +
" <br /> " +
" <b>Email cliente: " + email + " </b></p>" +
image.ToString
If FileUpload.HasFiles Then
For Each postedFile As HttpPostedFile In FileUpload.PostedFiles
Dim data As Attachment = New Attachment(Server.MapPath("~/images/") + postedFile.FileName, MediaTypeNames.Application.Octet)
Message.Attachments.Add(data)
'image.Append("<img src=" + """" + (Server.MapPath("~/images/") + postedFile.FileName + """" + "/>"))
Next
End If
Dim client As New SmtpClient()
Try
client.Send(Message)
Catch ex As Exception
' ...
End Try

Click Activation Email Link, Redirect to "Success" Page VB.NET

I've created a registration web form that redirects users to a page saying "Check your email to complete registration". The next step for them is to check their email and click the link provided in the email. Up to this point, everything works. However, when the link is clicked, it redirects them to the registration page again. I cannot figure out how to change this to go to the page designated for them that says "Your account is successfully been activated."
Using mm As New MailMessage("****#outlook.com", txtEmailAddress.Text)
mm.Subject = "Account Activation"
Dim body As String = "Hello " + txtFirstName.Text.Trim() + ","
body += "<br /><br />Please click the following link to activate your account"
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("VB.aspx", Convert.ToString("VB_Activation.aspx?ActivationCode=") & ActivationCode) + "'>Click here to activate your account.</a>"
body += "<br /><br />Thanks"
mm.Body = body
mm.IsBodyHtml = True
Dim smtp As New SmtpClient()
smtp.Host = "smtp.live.com"
smtp.EnableSsl = True
Dim NetworkCred As New NetworkCredential("****#outlook.com", "****")
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
Try
smtp.Send(mm)
Catch ex As Exception
MsgBox("Email was not sent")
End Try
End Using
I believe this line:
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("VB.aspx", Convert.ToString("VB_Activation.aspx?ActivationCode=") & ActivationCode) + "'>Click here to activate your account.</a>"
must be appended somehow with your website activation page.
Create the page VB_Activation.aspx within your web application and write code to activate the user using the ActivationCode that's being sent to it. If that file already exists make sure the filename in your code matches what you have created to handle activating the user.
Also, you could change this line:
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("VB.aspx", Convert.ToString("VB_Activation.aspx?ActivationCode=") & ActivationCode) + "'>Click here to activate your account.</a>"
To
body += "<br /><a href = 'http://www.yoursite.com/VB_Activation.aspx?ActivationCode=" & ActivationCode & "'>Click here to activate your account.</a>"

In HTML E-Mail, I can't go next line

I have funny problem in showing my emails in my boxes. As i send emails via my host ,it sends to my users successfully but in some part of my email text i want to go to the next line and i used tag to do that. the wieard thing is that in some mailboxes it go to the next line and in some others it doesn't go! for example the correct form is:
Dear Dr smith:
nice....
thank you very much
but it shows like this:
Dear Dr smith: nice.... thank you very much
here is my code:
MailMessage msg = new MailMessage();
StringBuilder bodyMsg = new StringBuilder();
msg.Subject = "Submission Confirmation";
bodyMsg.Append("<html><head><img src=" + "http://javahery21.ir/images/header.jpg" + ">" + "<title>CONFIRMATION EMAIL:</title></head><body>");
bodyMsg.Append("<br/>");
string link = string.Format("http://javahery21.ir/Activate.aspx?userID={0}", userID.ToString());
bodyMsg.Append("Dear " + RadioButtonList_Prefix.SelectedItem.Text + " " + name.Text + " " + middle.Text + " " + lastname.Text + ":<br/> Thank you for registering with Publishing manuscript submission system.");
bodyMsg.Append("To confirm and complete your registration<p>" + " " + "fallow this link" + "</p>.");
//bodyMsg.Append("<br/><br/>");
bodyMsg.Append("<br/>This link is active for 48 hours. If the link is not visited within this time frame, your registration will be discarded and you will need to register again.<br/><br/></br>Best regards,</br>Publishing<br/>http://***.com");
msg.IsBodyHtml = true;
msg.Body = bodyMsg.ToString();
msg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
msg.Priority = MailPriority.High;
// msg.ReplyTo = new MailAddress(TextBox2.Text);
msg.From = new MailAddress("***#***.**");
msg.To.Add(new MailAddress(TextBox_email.Text));
SmtpClient mailsender = new SmtpClient();
mailsender.Host = "SmtpClient.***.**";
mailsender.Port = 587;
mailsender.EnableSsl = true;
mailsender.Credentials = new System.Net.NetworkCredential("****#***.**", "classaspnet");
SmtpClient smtp = new SmtpClient();
//Literal1.Text = "<script>alert(' ')</script>";
smtp.Send(msg);
where did i make a mistake?
can any body help me?
Try using <p> tag.
Eg.
<p>Dear Dr smith:</p>
<p>nice....</p>
<br/>
<p>thank you very much</p>
You have missed out this
String msgText = getHtmlMessageText(...);
msg.setContent(msgText, "text/html");
You didnt set the content type for the message

Mail Format in asp.net?

In Web application, I'm trying to send mail to the user with an attachment, I'm sending mail to user but it is not in a good format this is my mail format which is written in asp.net.
StringBuilder stbldr =new StringBuilder();
stbldr.Append("<html><body>
<a href='http://*****/xyxi/mycheck/CheckAttachment.aspx?attid=" + s + "&Eid=" + t + "&afile=" + attach+ "' target='_blank'>Attachment..</a> " + cnt + " <br>
</body> </html>");
when mail send to user, the format in mail is same like above, it is displaying in all tags also like
try
message.Body = stbldr.ToString();
message.BodyFormat = MailFormat.Html;
message.From = txtemail.Text;
message.To = "xxx";
message.Subject = "test";
SmtpMail.SmtpServer = "sxxxxt";
SmtpMail.Send(message);
specify body format as html

Error while sending mail (attachment file)

in my application i am using to send mail with attachments i write the code like this
Using System.Net.Mail;
MailMessage mail = new MailMessage();
mail.Body = "<html><body><b> Name Of The Job Seeker: " + txtName.Text + "<br><br>" + "The Mail ID:" + txtEmail.Text + "<br><br>" + " The Mobile Number: " + txtmobile.Text + "<br><br>" + "Position For Applied: " + txtPostionAppl.Text + "<br><br>" + "Description " + txtdescript.Text + "<br><br></b></body></html>";
mail.From = new MailAddress ( txtEmail.Text);
mail.To .Add (new MailAddress ( mailid));
mail.Priority = MailPriority.High;
FileUpload1.PostedFile.SaveAs("~/Resume/" + FileUpload1.FileName);
mail.Attachments.Add(filenme);
SmtpMail sm = new SmtpMail();
sm.Send(mail);
it is giving error at attachment like mail.Attachemts.Add(filena)
like this
'System.Collections.ObjectModel.Collection.Add(System.Net.Mail.Attachment)' has some invalid arguments.
Your syntax is wrong. See this article for the correct syntax,
http://www.systemnetmail.com/faq/2.3.aspx
You can't add an attachment simply by specifying the filename. You have to specifically create an attachment object and add that. (as shown in the linked article.)
like this:
mail.Attachments.Add(new Attachment(filename));

Resources