Automatic E-mail

asif pasha

Registered User.
Local time
Today, 11:11
Joined
Jan 8, 2010
Messages
60
Hi
i have a small problem in sending the e-mail, what i am looking is when i update the record in the form and click on saved button, the code should send a mail from the outlook to the recepient available in one of the textbox.
Please help me with this, as my boss is hitting on my head.
 
Thns, i have already searched and trying.. anyway thanks for your help. and i think it works out.
 
Look at this code, you only need to subsitute the name with a me.textbox value

Sub sendForApproval()
'*************************************************
'VBA Code created by Trevor
'*************************************************
Dim olApp As Outlook.Application
Dim olMail As MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = "trevor@uk.com" '(not a real address)
.Subject = "Casualty Operations Database (COD) - Access Request"
.Body = "Please can you provide access to the CTD system." & vbCr & vbCr & _
"The required details are as follows my Full Name is: " & vbCr & _
"My User ID is: " & vbCr & _
"My Computer Name is: "
.Display

End With
Set olMail = Nothing
Set olApp = Nothing
End Sub
 
Hi

ive always preferred to set up public variables when using an email routine so i can call the same routine with different information.
Code:
Public strTo As String
Public strSubject As String
Public strBody As String

Sub sendForApproval()
'*************************************************
'VBA Code created by Trevor 
'*************************************************
Dim olApp As Outlook.Application
Dim olMail As MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = strTo '(not a real address)
.Subject = strSubject
.Body = strBody
.Display

End With
Set olMail = Nothing
Set olApp = Nothing
End Sub
you can then change the info from the form
Code:
Private Sub EmailSend()
strTo = Me.MyText
strSubject = Me.MySubjectText
strBody = "Please can you provide access to the CTD system." & _
vbCr & _
vbCr & _
"The required details are as follows my Full Name is: " & _
vbCr & _
"My User ID is: " & _
vbCr & _
"My Computer Name is: "

SendForApproval
End Sub

you can then change the variables numerous times to suit your needs without replicating the same routine many times


NS
 

Users who are viewing this thread

Back
Top Bottom