Results 1 to 13 of 13

Thread: VB Sendmail

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    11

    Question VB Sendmail

    Hey,

    Can anyone point me in the right direction to some good sites with free scripts?

    Im trying to send an email with an attachment - simply thou - the one iv got has got api/activex and sub classes/modules all over it.

    Many thanks

    ---------------------------------------------------------------------------
    There's a way around everything; even if it's the wrong way...

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VB Sendmail

    you cold use automation to send through outlook, but i prefer the vbSendmail, which is very simple to use

    you can use vbSendmail as a dll then just reference the dll
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    11

    Re: VB Sendmail

    Hey, yeah iv had a look at vbSendmail but I have trouble compiling it. When trying to run it, it says something about activex? I dont know exact error until i get back home, but if you know of any issues?

    Many thanks

    ---------------------------------------------------------------------------
    There's a way around everything; even if it's the wrong way...

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    11

    Re: VB Sendmail

    Also: why does vbsendmail save/get the information to the registry?

    ---------------------------------------------------------------------------
    There's a way around everything; even if it's the wrong way...

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: VB Sendmail

    Because that's how it's written. You can change that if you don't like it.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  6. #6
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,238

    Re: VB Sendmail

    I think vbSendmail needs to be in your Win\Sys folder and register it.
    Last edited by Keithuk; May 9th, 2007 at 01:55 PM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  7. #7
    Member
    Join Date
    May 2007
    Posts
    60

    Re: VB Sendmail

    This is what I use in all my apps...

    Code:
    ' For Windows 2000 you need to add a reference to
    '
    ' 	Microsoft CDONTS 1.2
    '
    ' For Windows XP the reference needed is
    '
    '	Microsoft CDO for Exchange 2000
    '
    Public Function SendMail() As Boolean
    
        Dim iMsg
        Dim iConf
        Dim Flds
        
    On Error GoTo Oops
         
    ' Windows XP or 2000?
        
    If Environ("systemroot") = "C:\WINDOWS" Then        ' Windows XP machine
        
            	Dim iMsg
    	Dim iConf
    	Dim Flds
    
    	Set iMsg = CreateObject("CDO.Message")
    	Set iConf = CreateObject("CDO.Configuration")
    	Set Flds = iConf.Fields
            
    	With Flds
    		.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    		.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailserver_IP_or_Name"  ' <- change this
    		.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
    		.Update
    	End With
            
    	With iMsg
    		Set .Configuration = iConf
    		.To = "someone@somewhere.com"
    		.Bcc = "secret@somewhere.com"
    		.From = "whoever@somewhereelse.com"
    		.Subject = "This is the subject line"
    		.HTMLBody = Some_Variable
                
    		.AddAttachment ("c:\somefile.jpg")
                
    		.Send
    
    	End With
            
    	Set iMsg = Nothing
    	Set iConf = Nothing
    	Set Flds = Nothing
    Else
    	 Dim NewMail As New CDONTS.NewMail
        
    	Set NewMail = CreateObject("CDONTS.NewMail")
        
    	NewMail.MailFormat = CdoMailFormatMime
    	NewMail.BodyFormat = CdoBodyFormatHTML
    	NewMail.From = "whoever@somewhereelse.com"
    	NewMail.Subject = "This is the subject line"
    	NewMail.Body = Some_Variable
    	NewMail.Bcc = "secret@somewhere.com"
    	NewMail.To = "someone@somewhere.com"
           
    	NewMail.AttachFile "c:\somefile.jpg"
            
    	NewMail.Send
            
    	Set NewMail = Nothing
    
    End If
        
    On Error Goto 0
       
    SendMail = True
        
    Exit Function
        
    Oops:
       
    SendMail = False
    
    End Function
    Hope it helps.

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    11

    Re: VB Sendmail

    Thanks for everyones reply, it appears that i had to "regsvr32.exe vbSendMail.dll" from command which registered the dll. This then worked when compiling the app.

    Thanks again

    ---------------------------------------------------------------------------
    There's a way around everything; even if it's the wrong way...

  9. #9
    Addicted Member
    Join Date
    Feb 2006
    Posts
    133

    Re: VB Sendmail

    Hey, you forgot password and login. Is it sample work through smtp?

  10. #10
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,238

    Re: VB Sendmail

    Quote Originally Posted by Keithuk
    I think vbSendmail needs to be in your Win\Sys folder and register it.
    Quote Originally Posted by Hardbyte
    Thanks for everyones reply, it appears that i had to "regsvr32.exe vbSendMail.dll" from command which registered the dll. This then worked when compiling the app.
    I told you to register it.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VB Sendmail

    Are looking for an smtp example of sending mail with VB6?

  12. #12
    Addicted Member
    Join Date
    Feb 2006
    Posts
    133

    Re: VB Sendmail

    Yes, with smtp authorization.

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VB Sendmail

    Try some of these.

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