 |
|
|
 |
|
 |
I dont understand why you want to suggest the new article. You can add any number of linked resource to the current view. Dont forget that this program is just a sample on the usage. The email is constructed inside the program rather sending it as a html text
Is there is anything you cant do?
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
When doing a google search for embedding images in an HTML email using vb.net, your article here was either at the top or close to it. This is a good example of creating an email with embedded images, but it wasn't precisely what I was looking for.
I needed to take an already existing HTML file and turn it into an email, images and all. I felt that if people were reviewing this article and learning about the ArticleView like I was, a logical next step would be the other article which includes regular expressions to find and replace the src values for the <img> and url() markup along with the additional code (that I was missing) to create a second AlternateView and transfer the resources over (because the body was modified after the original AlternateView was not created).
I was, like you, only hoping to add value here by getting people the resources they need to completely understand how to send an email with embedded images. I do not mean this other article to replace yours but to suppliment it. Perhaps the subject of the post was misleading, I will go back and edit it to make things clearer. If you still do not understand my reason for posting, or feel offended by it, reply to this message and I will come back and delete my post. </img>
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Hey if you are getting a .dat file then it means the coding is wrong. Please check your code again
Is there is anything you cant do?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I found i was getting embedded images as attachments myself, i fixed this by including the MIME type when creating the linked resource like so:
resource = New LinkedResource(Server.MapPath("Images\007jvr.gif"), "image/gif")
MIME Types available here: MIME Types[^]
For Fast Reference:
GIF = image/gif JPEG = image/jpeg PNG = image/png
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I know VB6 and I start VB.NET, so I want to know which book is the best basic simple programming?
regards
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hi dude, Book wont help in making you a programmer but yes it can teach you the syntax and for that reason MSDN is the best. I started my career in software with VB6 and ASP and so my suggestion is to trying your projects in .NET (please dont use the conversion wizard). Try to develop a 3 tier architecture with whatever you know in OOP. All the best
Is there is anything you cant do?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi i am senthil Iam a VB.net Programmer. I want to learn about AsP.Net(AJAX). I already have some idea about asp.net and i did 2 projects.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hiya,
You add the embedded resource but it doesn't look like you reference it in your message. It may or may not be in your download but I think it is worth changing your code snippet to use a message that displays the image.
That would make it easy for people to see how to construct the underlying HTML of the message so the images display properly.
Cheers! 
S
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
sorry i couldnt make out what you mean.. can you please be little more detailed?
Is there is anything you cant do?
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
msgText.Append("Hi there,") msgText.Append("Welcome to the new world programming.") msgText.Append("Thanks") msgText.Append("With regards,") msgText.Append("")
This is your message text. I cannot see where you make a reference to your embedded resource so that when the email is opened, the image displays. I suggest you change your snippet so that the message text displays the embedded resource.
It would make it easier to see how the embedded resource and message are linked together.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
View = AlternateView.CreateAlternateViewFromString(msgText.ToString(), Nothing, "text/html")
'link the resource to embed resource = New LinkedResource((Server.MapPath("Images\007jvr.gif")))
'name the resource resource.ContentId = "Image1"
'add the resource to the alternate view View.LinkedResources.Add(resource)
this is the place where the resource is embedded
Is there is anything you cant do?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
jebarson wrote: 'add the resource to the alternate view View.LinkedResources.Add(resource)
Yes I saw that.
You don't use that resource in your Html message though. You have an html email with an embedded image. But you don't appear to show how to display that image in the html in your message.
I hope that is clearer.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
i am sorry you didnt understand the code i guess...
msg.AlternateViews.Add(View)
this is the place where we add the resource to the html message.
Is there is anything you cant do?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Sorry, I understand the code quite well. Maybe I am being unclear. Its ok though, I was only trying to make your post better for future readers.
Have fun!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
You can't see the embedded image unless you add something like this to your message body: <img src="cid:Image1" />
If you added this it might help people use this code snippet.
Brett
|
| Sign In·View Thread·PermaLink | 4.00/5 (3 votes) |
|
|
|
 |
|
|
 |
|
 |
I am getting the following exception
System.Net.Mail.SmtpException was unhandled by user code Message="Failure sending mail." Source="System" StackTrace: at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.Page_Load(Object sender, EventArgs e) in d:\MyPractice\EmailSender\Default.aspx.cs:line 50 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
My code is as follows
protected void Page_Load(object sender,EventArgs e) { MailMessage msg = new MailMessage("madhuri.shekar@gmail.com","madhuri.shekar@gmail.com"); msg.IsBodyHtml = true; msg.Subject = "This is my first email through program";
AlternateView view = null; LinkedResource resource = null; SmtpClient client = null; StringBuilder msgText = new StringBuilder();
msgText.Append("Hi there, " ); msgText.Append("Welcome to the new world programming. " ); msgText.Append("Thanks " ); msgText.Append("With regards, " ); msgText.Append("<img src=cid:Image1 />");
view = AlternateView.CreateAlternateViewFromString(msgText.ToString(), null, "text/html");
resource = new LinkedResource((Server.MapPath("Images/007jvr.gif")));
resource.ContentId = "Image1";
view.LinkedResources.Add(resource);
msg.AlternateViews.Add(view);
client = new SmtpClient(); client.Host = "smtp.gmail.com"; client.EnableSsl = true; client.Credentials = new System.Net.NetworkCredential("username","pwd"); client.Send(msg); }
Mads
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hey could you please check whether u have entered username and pwd in the following statement?
client.Credentials = new System.Net.NetworkCredential("username","pwd");
if you have done this please send an email to me at jebarson007@gmail.com along your code.
Is there is anything you cant do?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
What are the namespaces to be included?
I am not able to create objects for the following AlternateView LinkedResource SmtpClient
Please help me..
Mads
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |