Visual Basic email system bcc mails [closed] - vb.net

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am making visual basic email software this software send attachment files and messages i want to send mails many companies i am adding To field but i want to add BCC and CC mail system also include but it don't have any idea how i code for this ..if any one have a good sense of this give me a idea ....
or any other way to add multiples mails system to with the attachment of Doc CV file .... i also need to know to add filter that someone not add any other format file to send .But mainly i need to know how to Add BCC blind carbon copy system in vb and CC carbon copy system..

Imports System.Net
Imports System.Net.Mail
Private mpMessage As MailMessage = Nothing
Private mpSMTPSvr As SmtpClient = Nothing
'------------------------------------------------------------------------
'-> Send The Message
'------------------------------------------------------------------------
MailerHost = "Addrss-of-your-emailer-host-server"
mpMessage = New System.Net.Mail.MailMessage()
mpMessage.Body = "Message body text goes here"
If Trim(SenderNameValue) <> "" Then
mpMessage.From = New System.Net.Mail.MailAddress("senderemail#hotmail.com", SenderNameValue)
mpMessage.Sender = New System.Net.Mail.MailAddress("senderemail#hotmail.com", SenderNameValue)
Else
mpMessage.From = New System.Net.Mail.MailAddress("senderemail#hotmail.com", "Name_Unspecified")
mpMessage.Sender = New System.Net.Mail.MailAddress("senderemail#hotmail.com", "Name_Unspecified")
End If
mpMessage.Priority = System.Net.Mail.MailPriority.High
mpMessage.Subject = "[WEB-REPONSE] - Correspondence via Website response form."
mpMessage.To.Add(Trim("recipient#yahoo.com"))
mpMessage.CC.Add(Trim("secretary#yahoo.com"))
mpMessage.BCC.Add(Trim("manager#yahoo.com"))
Try
mpSMTPSvr.Send(mpMessage)
SendStandardCommunicae = True
Catch ex As Net.Mail.SmtpException
ReturnErrorid = eEML_NETWORKERRORSENDINGEMAIL
ReturnErrorText = "A network error occurred whilst trying to send your message, please check your details for syntax errors and try again later.<br />If the error occurs consistently please contact the site administrator or use an alternative method of contact.<br /><br />"
ReturnErrorText = ReturnErrorText & "Extra Information:" & ex.Message
End Try

Related

How to solve Socket Accept Timeout [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a power on-off device to control. If the device is connected to the network, my code works fine. I remove the device from the network on purpose to test it as if the device malfunctions (like power off). And I find out that the System hangs.
I trace that the socket.accept does not execute - 'accept is ok' is not written to a log file. ex.message does not write as well.
My purpose is to send a message to support if there is any device malfunction.
Using gSocket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
WriteLog("Start. ")
Dim remoteSocket As Socket
Try
gSocket.SendTimeout = 5000
gSocket.ReceiveTimeout = 5000
gSocket.Bind(vEndPoint) ' vEndpoint is the local machine
WriteLog("bind is ok. ")
gSocket.Listen(10)
WriteLog("listen is ok. ")
remoteSocket = gSocket.Accept
WriteLog("accept is ok. ")
Catch ex As Exception
WriteLog(ex.Message)
Finally
End Try
How can I solve this?
I use BeginAccept to solve it.
Dim acceptResult As IAsyncResult = gSocket.BeginAccept(Nothing, Nothing)
Dim Success As Boolean = acceptResult.AsyncWaitHandle.WaitOne(vTimeout, True)
If Success Then
remoteSocket = gSocket.EndAccept(acceptResult)
WriteLog("beginaccept is ok. ")
Else
gSocket.Close()
WriteLog("beginaccept failed. ")
End If

Why is My.Computer not working in visual basic .NET console app? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Why isn't this working. I tried this on a school computer (fully reimaged and running on a network) and it worked fine
Yet, when I try it on my home pc (newly installed visual studio 2019)
it throws the exception:
Computer is not a member of projectname. My
Code is here:
Imports System
Module Program
Sub Main(args As String())
Dim fileReader As System.IO.StreamReader = My.Computer.FileSystem.OpenTextFileReader("D:\\story1.txt")
Dim stringReader As String = ""
Dim i As Integer = 1
Dim TotalString As String = ""
While stringReader <> "*"
stringReader = fileReader.ReadLine()
If i Mod 2 = 0 Then
TotalString += stringReader
End If
End While
Console.WriteLine(TotalString)
Console.ReadKey()
End Sub
End Module
Sorry about this - I was using the wrong type of application. I used type Console app .NET core instead of Console app .NET Framework
I apologize for any inconvenience.

Get antivirus name from wscui.cpl with vb.net [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am looking for away to get this value:
I am building a program that will be installed on 100s of computers and servers. And i need to figure out how i can get the name of the anti virus in vb.net.
This can also be a powershell script. It is possible to read the output from a powershell script in vb.net
The problem is: With all the scripts that I could find any where it was not able to even get my own antivirus. There needs to be a way to read the information from the control panel right? Or is that impossible.
So after some searching i found this: with SecurityCenter2. For me this works
Dim IPAddress As String = "127.0.0.1"
Dim connectionOptions As New ConnectionOptions()
connectionOptions.EnablePrivileges = True
connectionOptions.Impersonation = ImpersonationLevel.Impersonate
Dim managementScope As New ManagementScope(String.Format("\\{0}\root\SecurityCenter2", IPAddress), connectionOptions)
managementScope.Connect()
Dim objectQuery As New ObjectQuery("SELECT * FROM AntivirusProduct")
Dim managementObjectSearcher As New ManagementObjectSearcher(managementScope, objectQuery)
Dim managementObjectCollection As ManagementObjectCollection = managementObjectSearcher.[Get]()
Dim antivirus As String = ""
If managementObjectCollection.Count > 0 Then
For Each item As ManagementObject In managementObjectCollection
antivirus = antivirus + item("displayName") + " - "
Next
antivirus = antivirus.Remove(antivirus.Count - 3, 3)
End If

how to check details before sending mails in outlook using macros? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have to send mails to many different groups and sometimes I send to the wrong group.
I want to create VBA code to check, the initial two letters of subject header and also whether the same two initial letters are present in the mail body, as I send the mail. If the escalation is correct then mail should be sent otherwise the code should display some error message.
It looks like you need to handle the ItemSend event of the Application class which is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program. Be aware, the Cancel parameter passed to the event handler allows to cancel the action. If the event procedure sets this argument to true, the send action is not completed and the inspector is left open.
Public WithEvents myOlApp As Outlook.Application
Public Sub Initialize_handler()
Set myOlApp = Outlook.Application
End Sub
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & Item.Subject & "?"
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
Cancel = True
End If
End Sub
In the code you can check out whatever you need - the Subject, Body or HTMLBody values.

Read and write to the registry with VB.NET [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I made a game and I would like to store the high score and other values in the windows registry. It's made in VB.NET. Could someone give me a sample code example of simple reading and writing to the registry.
Thanks
You must open Registry sub Key before read or write. Then you can read or write
Dim regKey As RegistryKey
Dim Value As Object
regKey =My.Computer.Registry.CurrentUser.OpenSubKey("HKEY_CURRENT_USER\Software\VB_and_VBA_Program_Settings", True)
'Here u can read value of AppName
Value = regKey.GetValue("AppName", "Default Value")
'Or u can write the value
value=regkey.setValue("AppName", "myApp")
regKey.Close()
Simply...
Imports Microsoft.VisualBasic
Dim s As String
SaveSetting("(AppName)", "(SectionName)", "(Key)", "(Your Value)")
s = GetSetting("(AppName)", "(SectionName)", "(Key)", "(Default Value)")
Replace (AppName), (SectionName), (Key) with appropriate values. The data will be saved in HKEY_CURRENT_USER\Software\VB and VBA Program Settings\(AppName)
http://www.vbdotnetheaven.com/UploadFile/mahesh/WindowsRegistry04262005045814AM/WindowsRegistry.aspx
http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx
I'm more comfortable with C#, but it's pretty straightforward with VB.NET too. Here's an example of how to write to the registry, and another example of how to read from the registry. Don't forget to import the Microsoft.Win32 namespace.
You can use registry.getvalue and registry.setvalue. Here are a couple of examples used for default file types:
Registry.GetValue("HKEY_CURRENT_USER\software\classes" & "\" & fileFormatExt(i), "", "error")
Registry.SetValue("HKEY_CURRENT_USER\software\classes\" & FileType, "", appTag) ' set new value, overwrite any other, creates key if not there.