Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Email Accounts from VB6 / MS Access

Status
Not open for further replies.

lassehammer

IS-IT--Management
Joined
May 10, 2004
Messages
9
Location
GB
Hi There,

I've just started using code in my Access databases. I've managed to write code which allows me to automatically send emails from a click box on an access form. However I need to find a way of specifying which email account to send the email from.

The code I have at present is ..

Code:
 Private Sub SendMail(strTo As String, strSub As String, strMsg1 As String, strMsg2 As String, strMsg3 As String, strMsg4 As String, strMsg5)
     
    Dim olApp As Outlook.Application
    Dim olMessage As MailItem
     
    Set olApp = CreateObject("Outlook.Application")
   
     
    
    Set olMessage = olApp.CreateItem(olMailItem)
    olMessage.To = strTo
    olMessage.Subject = strSub
    olMessage.Body = strMsg1 & vbCrLf & vbCrLf & strMsg2 & vbCrLf & vbCrLf & strMsg3 & vbCrLf & vbCrLf & strMsg4 & vbCrLf & vbCrLf & strMsg5
    olMessage.Send
     
   
     
    Set olApp = Nothing
    Set olNS = Nothing
    Set olMessage = Nothing
     
End Sub

Any help will be greatfully apppreciated

Regards

Lasse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top