Click here to Skip to main content
15,113,692 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i'm create one form like name age address cotacts comments user to type all that tab i need to save that all details in word format and i need to attach file in browse button and save that file in other location and i want to send mail in all the above details with attachment and i dnt want to open other window to send mail i just want to sigle click and and that detail will send mail that particular mail ID example@gmail.com like that user dnt want to change the mail ID..


pls help me.....
Posted
Updated 20-Aug-20 6:53am

1 solution

To Save file you can use FileStram and StreamWriter Classes form System.Io
For Example :
VB
'Creating object of FileStream.Full filePath is the path where you want to 'Save the file and FileMode is Open/Create/CreateOrOpen.
Dim fs As FileStream=New FileStrea("FullFilePath","FileMode")
Dim sw as StreamWriter=New StreamWriter(fs)
'Writting Textbox Values into the File
sw.writeline("Textbox1.Text")
sw.writeline("Textbox2.Text")
'Closing FileStream
sw.Close
fs.Close
'Disposing the Objects
sw=Nothing
fs=Nothing


To send Mail on One Click use Following Code :
' place the following code in a command button click event
VB
Private Sub cmdSendMail_Click()
    Dim objOutlook As Outlook.Application
    Dim objMailItem As Outlook.MailItem
    Set objOutlook = New Outlook.Application
    Set objMailItem = objOutlook.CreateItem(olMailItem)
    With objMailItem.To = "ToAddress"  'recipient's address
        .Subject = "subject"  'subject box content
        .Body = "email message"  ' message goes here
        .Attachment = "c:\path\file.txt"    ' attach any files here
        .Send
    End With
    Set objMailItem = Nothing
    Set objOutlook = Nothing
End Sub
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900