Using outlook express in vb.net2003
Hai,
Is there anyone who can tell me how to use outlook express in vb.net2003?
I would like that when i click on my mailbutton that outlook express opens. I would also that i can attach a selected picture from my paint program. I don't know how to do :cry:
Anyone who can help me?
Greetz
Re: Using outlook express in vb.net2003
The only way to do what you want is to start a process with the "mailto:' protocol. You can not automate or program Outlook Express since it doesnt expose any valid COM interfaces.
VB Code:
System.Diagnostics.Process.Start("mailto:
[email protected]?subject=test&body=test&attach=" & Chr(34) & strFileToAttach & Chr(34) & ")
Re: Using outlook express in vb.net2003
How do I get the picture as attachment in the mail? It always ask after a string. The image i will send is in a picturebox :ehh:
Re: Using outlook express in vb.net2003
You could also look into System.Web.Mail. It's pretty straight forward and allows attachments.
VB Code:
Dim mail As New System.Web.Mail.MailMessage
Dim smtp As System.Web.Mail.SmtpMail
mail.Priority = Web.Mail.MailPriority.Normal
mail.Subject = "subject"
mail.Body = "body"
Dim att As New System.Web.Mail.MailAttachment("C:\test2.bmp")
mail.Attachments.Add(att)
smtp.Send(mail)
Re: Using outlook express in vb.net2003
Hello,
On your code it gives errors. It says it don't recognize System.Web.Mail.MailMessage :s
Re: Using outlook express in vb.net2003
You have to add a reference to System.Web.
Robdog has a better solution if you can make it work. It will use your system's default settings instead of tring to go around them.
Re: Using outlook express in vb.net2003
I just wanted to note that I remember reading that attaching a file is not part of the official MAILTO: syntax... so while it may work if the specific email client supports it, its not guaranteed that it will work with every mail client.
Re: Using outlook express in vb.net2003
I should have also asked, are you using an SMTP engine for your mail server? Or is it POP3 or http? This is only going to work with smtp, http and pop3 have their own mechanics.
Re: Using outlook express in vb.net2003
Yes, thats right klienma. You also need to parse out the special characters and replace them with their web hex equilivalent.
Re: Using outlook express in vb.net2003
I'm using an SMTP server. So when i use this code System.Diagnostics.Process.Start("mailto:[email protected]?subject=test&body=test&attach=" & Chr(34) & strFileToAttach & Chr(34) & ") Can i attach something from my picturebox then?
Re: Using outlook express in vb.net2003
Yes, but the filepath needs to be in the variable - strFileToAttach and be formatted so the path chars are correctly converted to hex.
Re: Using outlook express in vb.net2003
Quote:
Originally Posted by RobDog888
Yes, but the filepath needs to be in the variable - strFileToAttach and be formatted so the path chars are correctly converted to hex.
somthing like this: Dim StrAttachment As String = CStr(PictureBox1.Image) or.... But this doesn't work :rolleyes:
Re: Using outlook express in vb.net2003
Nope, it wont because your trying to attach a binary image instead of a file on your hard drive and replace the invalid chars with their Hex equilivalent.
Re: Using outlook express in vb.net2003
So can you give an example please, my english isn't very well.
Re: Using outlook express in vb.net2003
You need to save the image file to your disk. Then use that file path to pass into the attachment argument with the bad chars converted to hex.
VB Code:
C:\Some path\some file.txt
'Should be having the :\ and spaces as hex
%20 = space
'not sure what the other two would be.
'This is partially converted.
C:\Some%20path\some%20file.txt
Re: Using outlook express in vb.net2003
Thx, but is there also a posibility to get a picture from a database and then set them in the mail?
Re: Using outlook express in vb.net2003
I think you might want to edit post #15 Rob. :lol:
Re: Using outlook express in vb.net2003