Skip to content

Instantly share code, notes, and snippets.

View discarn8's full-sized avatar

discarn8 discarn8

View GitHub Profile
@discarn8
discarn8 / Extract_data_from_emails_write_to_text_file.vba
Created May 16, 2018 22:28
OUTLOOK - Extract_data_from_emails_write_to_text_file.vba
Public Sub EXTRACT_INFORMATION()
Dim var1, var2, var3, var4, WL, em, WLC, oFSO, oFS, fso, bstring, When, var5 As String
Dim MsgCount, var6, var7, var8, var9, ErrCheck, var10 As Integer
Dim rrVar, lrVar, rdVar, ldVar, lsVar, rsVar, lc, Target
Dim oMailS As Outlook.MailItem
' --------------------------------------------------------------------
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = Application.ActiveExplorer.CurrentFolder.Items
Set colItems = objFolder
@discarn8
discarn8 / Prefab_Reply_from_html_file.vba
Created May 16, 2018 22:47
OUTLOOK - Prefab_Reply_from_html_file.vba
' Canned reply using external html
Public Sub PREFAB_REPLYNew()
Dim oMailReply, oMailSelect As Outlook.MailItem, Keyword5 As String
Dim oFSO, oFS, BodyText, SubjString, EmpFirst, EmpLast, BodyReply
If Application.ActiveExplorer.Selection.Count Then
If TypeOf Application.ActiveExplorer.Selection(1) Is Outlook.MailItem Then
@discarn8
discarn8 / Query_mdb.vba
Created May 16, 2018 22:50
OUTLOOK - Query_mdb.vba
Public Sub servers()
On Error GoTo errHandler
Dim db_Name As String
db_Name = ("c:\servers.mdb")
Dim DB_CONNECT_STRING As String
DB_CONNECT_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"data Source=" & db_Name & ";" & ", , , adConnectAsync;"
@discarn8
discarn8 / Export_email_messages_to_mht_files_and_save_attachments.vba
Last active July 26, 2018 05:26
OUTLOOK - Export_email_messages_to_mht_files_and_save_attachments.vba
' Save files as mht file to storage device
' Highlight the messages to archive and then run script
Public Sub samht()
Const olFolderInbox = 6
Dim i As Integer
Dim k As Integer
Dim m As Integer
Dim x As Integer
Dim CU As String
Dim strFName As String
@discarn8
discarn8 / Clear_Annoying_Stationary.vba
Last active May 16, 2018 22:58
OUTLOOK - Clear_Annoying_Stationary.vba
'Clear annoying stationary in an email
'tested with Office 2003, office 2007 and Office 365
'Highlight the message and then run the script
Sub ClearStationeryFormatting()
On Error GoTo ClearStationeryFormatting_Error
Dim strEmbeddedImageTag As String
Dim strStyle As String
Dim strReplaceThis As String
Dim intX As Integer, intY As Integer
Dim myMessage As Outlook.MailItem
@discarn8
discarn8 / Save_attachments.vba
Created May 16, 2018 23:02
OUTLOOK - Save_Attachments.vba
Public Sub SaveAttachments()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem 'Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strDeletedFiles As String
@discarn8
discarn8 / shell_script_check_for_conky_restart_if_not_found.sh
Created May 17, 2018 07:12
BASH - shell_script_check_for_conky_restart_if_not_found
#! /bin/bash
# Don't forget to add this script to your cron
logfile="/var/log/conky_check.log"
case "$(pidof conky | wc -w)" in
0) echo "conky found not running, (re)starting conky: $(date)" >> $logfile
DISPLAY=:0 /home/user/.conky/conky_start &
@discarn8
discarn8 / shell_script_delete_folders_older_than.sh
Last active May 17, 2018 07:21
BASH - shell_script_delete_folders_older_than
# Useful for purging security camera folders
# 1 0 * * * = Run at 12:01a every day
# -name '2018*' just means - find all folders that start with 2018
# -type d = folders
# -mtime +20 = modified 20 days ago
1 0 * * * /bin/find /home -maxdepth 3 -name '2018*' -type d -mtime +20 -exec rm -rf {} \; -print >> /root/purge.log
@discarn8
discarn8 / Clear_sheets.vba
Created May 18, 2018 18:26
EXCEL - Clear_sheets.vba
Option Explicit
Sub CLEARDATA()
On Error GoTo ErrHandler
Dim arrSHEETS As Variant
Dim wsheets As Variant
arrSHEETS = Split("Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,Golf,Hotel", ",")
@discarn8
discarn8 / No_Save_Auto-Close.vba
Created May 18, 2018 18:28
EXCEL - No_Save_Auto-Close.vba
Sub Auto_Close()
ThisWorkbook.Saved = True
End Sub