Results 1 to 18 of 18

Thread: Using outlook express in vb.net2003

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    13

    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
    Anyone who can help me?

    Greetz

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. System.Diagnostics.Process.Start("mailto:[email protected]?subject=test&body=test&attach=" & Chr(34) & strFileToAttach & Chr(34) & ")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    13

    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

  4. #4
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    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:
    1. Dim mail As New System.Web.Mail.MailMessage
    2.         Dim smtp As System.Web.Mail.SmtpMail
    3.  
    4.         mail.To = "[email protected]"
    5.         mail.From = "[email protected]"
    6.         mail.Priority = Web.Mail.MailPriority.Normal
    7.         mail.Subject = "subject"
    8.         mail.Body = "body"
    9.  
    10.         Dim att As New System.Web.Mail.MailAttachment("C:\test2.bmp")
    11.         mail.Attachments.Add(att)
    12.  
    13.         smtp.Send(mail)
    Last edited by sevenhalo; Feb 21st, 2006 at 12:22 PM.

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    13

    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

  6. #6
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    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.

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  8. #8
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    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.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    13

    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?

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    13

    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

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    13

    Re: Using outlook express in vb.net2003

    So can you give an example please, my english isn't very well.

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. C:\Some path\some file.txt
    2.  
    3. 'Should be having the :\ and spaces as hex
    4. %20 = space
    5. 'not sure what the other two would be.
    6. 'This is partially converted.
    7. C:\Some%20path\some%20file.txt
    Last edited by RobDog888; Mar 1st, 2006 at 03:19 AM. Reason: type-o
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    13

    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?

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Using outlook express in vb.net2003

    I think you might want to edit post #15 Rob.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Using outlook express in vb.net2003

    Done.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width