I have looked through the code but I simply do not have the understanding to know what functions are doing what and how in relation to C# my primary coding language.
Set mSkype = WScript.CreateObject("Skype4COM.Skype", "Skype_")
ContactName=InputBox ("Enter the contact's Skype User Name" & CHR(13) & "Note that this must be the User Name and not the Display Name", "User Name:")
If ContactName = "" Then
WScript.Quit
Else
If mSkype.User(ContactName).FullName="" then
WScript.Echo ("The name " & ContactName & " is not in your Contact List")
WScript.Quit
End If
End If
PictureFileName=InputBox ("Enter the path and name of the Picture" & CHR(13) & "The file extension must be .jpg", "Save Picture as:")
If PictureFileName="" Then
WScript.Quit
End If
cmdStr = "GET USER" & " " & ContactName & " " & "AVATAR 1" & " " & PictureFileName
mSkype.SendCommand mSkype.Command(0, cmdStr)
Oh and I do have skype4com imported and im using that api, that is not the issue with conversion.
InputBox is a window that displays that prompts for input. It is available in VB.NET, and you can actually use it in C# by adding a reference to Microsoft.VisualBasic. See here.
WScript is also not available in VB and it would probably be good to research how to use the Skype plugin in the Skype Developer Forum. Here's a link about how to use the Skype DLL in C#.
Related
We are currently developing an addin that interact with the end user visually to give some informations, and we wanted to use Mailtips but apparently it is not possible from what we saw
Nevertheless, is it possible to have something similar or to mimic this kind of tip (2nd sshot would be ideal)..
Option 1:
https://i.stack.imgur.com/vcQYb.png
Option 2:
https://i.stack.imgur.com/7k19w.png
We also looked and form region but that would be the last option, ideal would be to have the tooltip in 2nd screenshot to display a small message to help user (any clue appreciated).
We were also looking for a function to disable links in the body (as the junk filter does), but also no chance finding this through the documentation (maybe internal procedure)
Looking everywhere for documented elements...
On the screenshot you have seen a standard Outlook notification and MailTips - that is a feature of Exchange, not Outlook.
We also looked and form region but that would be the last option, ideal would be to have the tooltip in 2nd screenshot to display a small message to help user (any clue appreciated).
The Outlook object model doesn't provide anything for that, there is no built-in property or method for that. The only possible option is to use a form region where you could put your custom UI at the bottom of the standard form/window in Outlook. The Adjoining layout available for Outlook form regions appends the form region to the bottom of an Outlook form's default page. So, if you want to place the form at the top you need to use Windows API functions to subclass Outlook windows or consider using the Advanced Outlook view and form regions where the top layout is provided out of the box.
Also you may consider developing a web add-in for Outlook where you could set up notification items programmatically from the add-in, see Office.NotificationMessages interface for more information. For example:
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml
const id = $("#notificationId").val();
const details =
{
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
message: "Non-persistent informational notification message with id = " + id,
icon: "icon1",
persistent: false
};
Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult);
See Build your first Outlook add-in to get started quickly on that.
We were also looking for a function to disable links in the body (as the junk filter does), but also no chance finding this through the documentation (maybe internal procedure)
You need to process the message body on your own. The Outlook object model doesn't provide any property or method for that out of the box.
The Outlook object model supports three main ways of customizing the message body:
The Body property returns or sets a string representing the clear-text body of the Outlook item.
The HTMLBody property of the MailItem class returns or sets a string representing the HTML body of the specified item. Setting the HTMLBody property will always update the Body property immediately.
The Word object model can be used for dealing with message bodies. See Chapter 17: Working with Item Bodies for more information.
You can add a special MAPI property (used by Web addins, DASL name "http://schemas.microsoft.com/mapi/string/{A98A1EF9-FF40-470B-A0D7-4D7DCE6A6462}/WebExtNotifications") to show the notification banner.
Something along the following lines (VBA, you'd need to deselect and select again the currently selected message to see the change):
notificationXml = "<?xml version=""1.0""?>" & vbCrLf & _
"<Apps>"& vbCrLf & _
" <App id=""00000000-0000-0000-0000-000000000000"">"& vbCrLf & _
" <Notifications>"& vbCrLf & _
" <Notification key=""notification"">"& vbCrLf & _
" <type>0</type>"& vbCrLf & _
" <message>Test notification
with two lines</message>"& vbCrLf & _
" </Notification>"& vbCrLf & _
" </Notifications>"& vbCrLf & _
" </App>"& vbCrLf & _
" <App id=""00000000-0000-0000-0000-000000000001"">"& vbCrLf & _
" <Notifications>"& vbCrLf & _
" <Notification key=""notification"">"& vbCrLf & _
" <type>0</type>"& vbCrLf & _
" <message>Another notification</message>"& vbCrLf & _
" </Notification>"& vbCrLf & _
" </Notifications>"& vbCrLf & _
" </App>"& vbCrLf & _
"</Apps>"
set msg = Application.ActiveExplorer.Selection(1)
msg.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/string/{A98A1EF9-FF40-470B-A0D7-4D7DCE6A6462}/WebExtNotifications", notificationXml
msg.Save
I want to change MTU value for windows 7/8.1/10 with C#.
I tried to search on Stack Overflow but only netsh is what I can find.
Get current MTU value
Set custom MTU value
I don't want to use any cmd commands, any idea to do with C# only?
You should be able to use the WMI API for this.
There's a Visual Basic example you can probably adapt:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetMTU(68)
The SetMTU method is documented here, and the C# APIs to talk with WMI are documented here.
Is there any way to delete history & cookies of Microsoft Edge browser using VBScript or .net?
Like Internet Explorer, deleting the history form "%AppData%\Local\Microsoft\Windows\History" folder or Rundll32 commands?
Rundll32 commands
Delete Cookies:
rundll32.exe,InetCpl.cpl,ClearMyTracksByProcess 2
Delete History:
rundll32.exe,InetCpl.cpl,ClearMyTracksByProcess 1
Edit:
Found an solution for clearing cookie http://winhelp2002.mvps.org/cookies.htm. Deleting files from following 4 folders will clear cookies without affecting history and cache.
1. \Users\user name\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\#!001\MicrosoftEdge\Cookies
2. \Users\user name\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\#!002\MicrosoftEdge\Cookies
3. \Users\user name\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\#!121\MicrosoftEdge\Cookies
4. \Users\user name\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\MicrosoftEdge\Cookies
Still need help to clear history without affecting cookie and cache
This is not Safe But First You need To Close Microsoft Edge browser, Then you should delete All Sub_Folders and Files are in :
"C:\Users\[username]\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"
Change [username] with your own Windows Username.
VB Script Code :
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("C:\Users\[username]\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe")
for each f in folder.Files
On Error Resume Next
name = f.name
f.Delete True
If Err Then
WScript.Echo "Error deleting:" & Name & " - " & Err.Description
Else
WScript.Echo "Deleted:" & Name
End If
On Error GoTo 0
Next
For Each f In folder.SubFolders
On Error Resume Next
name = f.name
f.Delete True
If Err Then
WScript.Echo "Error deleting:" & Name & " - " & Err.Description
Else
WScript.Echo "Deleted:" & Name
End If
On Error GoTo 0
Next
Note : Run This Source AS ADMIN
Another Way :
Call WshShell.Run("powershell -command Get-AppXPackage -AllUsers -Name Microsoft.MicrosoftEdge | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml” -Verbose}")
RUN AS ADMIN TOO
I used this code to create a scheduled task in vb.net, now I'm learning C# and want to make this code to work with C#:
`Shell("schtasks.exe /create /TN " & ChrW(34) & "Updataas\AAMyname task" & ChrW(34) & " /XML " & ChrW(34) & path & ChrW(34))`
You may want to use Process.Start:
Process.Start("schtasks.exe", "/create /TN \"Updataas\\AAMyname task\" /XML \"" + path + "\"");
Can anyone tell me how to read the custom Field value of the outlook using c#
Right now i tried "UserProperties" and "ItemProperties". Both are throwing error. My sample code as follows
Microsoft.Office.Interop.Outlook.Application f = new Microsoft.Office.Interop.Outlook.Application();
NameSpace outlookNS = f.GetNamespace("MAPI");
MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
foreach (object obj in inboxFolder.Items)
{
MailItem item = obj as MailItem;
if (item != null)
{
Console.WriteLine(item.UserProperties["test"].Value);
Console.WriteLine(item.ItemProperties["test"].Value);
}
}
Thanks in advance
This answer has been rewritten following experiments with Outlook.
My C# is good enough for me to know what you are doing but I have not tried to access Outlook from C# yet.
Both Items and Item are used within the Outlook model. I do not know it you can use item in the way you are attempting.
UserProperties would throw an error if user property "test" did not exist. Below I show how to test for existence. Are you adding a user property and forgetting to save the amended mail item?
The following shows access to user properties from Outlook VBA. I would expect the InterOp model to be as similar as the syntax allows. Important differences of which I know:
Set is not required with C#.
Nothing is the VBA equivalent of null.
Variables:
FolderItem is an item within a folder that has been tested to be of class olMail.
UserProp is of type UserProperty.
InxUP is of type integer.
The following adds a user property with name "TestProp" and type olText, sets its value to "Value for TestProp" and saves the amended mail item. Without the Save, the previous statements have no effect.
With FolderItem
Set UserProp = .UserProperties.Add("TestProp", olText)
UserProp.Value = "Value for TestProp"
.Save
End with
The following outputs to the immediate window the name and value of every user property against the mail item.
For InxUP = 1 To .UserProperties.Count
Debug.Print " User prop " & InxUP & _
.UserProperties(InxUP).Name & " " & _
.UserProperties(InxUP).Value
Next
The following checks that user property "TestProp" exists and, if so, outputs its value to the immediate window.
Set UserProp = .UserProperties.Find("TestProp")
If Not UserProp Is Nothing Then
Debug.Print " TestProp " & .UserProperties("TestProp").Value
End If
Hope this helps
This reply might be a bit late for you. But I came across the same problem as the original poster (need to extract values from User-Defined Fields (Custom fields) of Outlook).
Someone somewhere shared a VBA macro which did the job. So I went around looking for a way to execute Outlook macro VBA in powershell. As it turns out Outlook stopped supporting /autorun of macro after version 2003 SP2. I nearly switched from Outlook 2019 to Outlook 2003 just for the /autorun. Then it occurred to me Outlook 2003 isn't as good with showing multiple calendars side by side as Outlook 2019. So I decided to keep going with 2019 afterall. Cut long story short, I massaged the VBA macro to run in Powershell and it worked for me. I basically added in a few dollar signs in front of things, and removed some stuff here and there, and then it just worked. I hope it works for everyone else too who is still looking for answer:
Function Get-ContactUDF
{
Add-Type -assembly "Microsoft.Office.Interop.Outlook" -ErrorAction Stop -ErrorVariable "OutlookError"
$Outlook = New-Object -comobject Outlook.Application -ErrorAction stop -ErrorVariable "ApplicationError"
$objNameSpace = $Outlook.GetNameSpace("MAPI")
$objContacts = $objNameSpace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderContacts)
$objContact = $objContacts.Items.Find("[FirstName] = ""John""")
$objProperty = $objContact.UserProperties.Find("Favorite Character in Lord of the Rings")
$objProperty.Value
}
Just in case the code is not clear. This powershell function will look for the Contact whose FirstName is "John", and then find the value under the custom field called "Favorite Character in Lord of the Rings" and print out the value (for example Frodo). To run it, ofcourse you just do this under powershell:
Get-ContactUDF
By the way if you just want to print values from default fields (those built-in fields that came with Outlook eg. Firstname, Surname, Birthday, phone number, spouse name, title etc), then it's like the following:
Function Get-OutlookContacts
{
Add-Type -assembly "Microsoft.Office.Interop.Outlook" -ErrorAction Stop -ErrorVariable "OutlookError"
$Outlook = New-Object -comobject Outlook.Application -ErrorAction stop -ErrorVariable "ApplicationError"
$namespace = $Outlook.GetNameSpace("MAPI")
$contactObject = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderContacts)
}
Call this function by just typing:
Get-OutlookContacts
in Powershell
THIS WILL LIST EVERYTHING IN THE CONTACTS DATABASE:
$contactObject.Items
THIS WILL LIST ALL OBJECTS FIRSTNAME, LASTNAME, BIRTHDAY, EMAILADDRESS, MOBILE IN THE CONTACTS DATABASE:
$contactObject.Items | Select-Object -Property FirstName, LastName, Birthday, Email1Address, MobileTelephoneNumber
ISSUE this next command to grab objects and list only for where the firstname object equals Rambo:
$contactObject.Items | Select-Object -Property FirstName, LastName, Birthday, Email1Address, MobileTelephoneNumber | where-object {$_.Firstname -eq "Rambo" }
Hope these examples are clear. I use Outlook 2019 on Windows 10 totally offline mode (no cloud, no 365). If you use 365 then the code above probably needs modifications.
I also remember other people asking for a way to extract Outlook Calendar events using Powershell. If I come across that question again I'll post the answer. Basically the same drill. I read some VB code from somewhere and then turned it into Powershell script. You guys can do it yourself if you like. Just add in dollar signs and remove the DIM lines.