Showing posts with label Email. Show all posts
Showing posts with label Email. Show all posts

Thursday, October 14, 2021

Outlook Imap and SMTP Setting

(Anhgolden's Blog) - Thông số cấu hình liên quan đến email Outlook
Imap:
Server name: outlook.office365.com
Port: 993
Encryption method: TLS

SMTP:
Server name: smtp.office365.com
Port: 587
Encryption method: STARTTLS





Read More »

Wednesday, December 10, 2014

Turn on or off Auto-Complete List name suggestions

Turn on or off Auto-Complete List name suggestions

The Auto-Complete List is a feature which displays suggestions for names and e-mail addresses as you begin to type them. These suggestions are possible matches from a list of names and e-mail addresses from the e-mail messages that you have sent.





Auto-Complete list
By default, this feature is turned on in Outlook. To turn on or off Auto-Complete List name suggestions, do the following:
  1. Click the File tab.
  2. Click Options.
  3. Click Mail.
  4. Under Send messages, select or clear the Use Auto-Complete List to suggest names when typing in the To, Cc and Bcc lines check box.


Related:
https://support.office.com/en-ca/article/Delete-a-name-from-the-AutoComplete-list-2e3d8fb1-eefd-4307-ab73-6f2f23164222
Read More »

Friday, November 22, 2013

Tự động bật tắt Rule trong Ms Outlook theo thời gian

(Anhgolden's Blog)-Sưu tầm

Trong ms outlook có tính năng "Rules and Alerts" nhằm thiết lập Rule cho Email. Chọn check hoặc uncheck vào Rule nếu muốn Enable hoặc Disable Rule. Tuy nhiên, ms outlook không cho phép chúng ta muốn thiết lập chế độ tự động Enable hoặc Disable Rule theo thời gian. Muốn đáp ứng nhu cầu trên, xin chia sẻ bài viết hướng dẫn thực hiện bằng VBA kết hợp với chế độ Reminder có sẵn của ms outlook.

Lưu ý: Chương trình chỉ chạy khi Outlook được mở.

Bước 1: Hãy tạo Task với subject là "Disable Rule", "Enable Rule" và thiết lập Reminder time.

Bước 2: Tạo Script sau
Bấm Alt+F11 để mở VBA Editor và paste đoạn code sau vào phần "ThisOutlookSession".
Private Sub Application_Reminder(ByVal Item As Object) 
  
If Item.MessageClass <> "IPM.Task" Then
  Exit Sub
End If
  
If Item.Subject = "Enable Rule" Then
  Enable_Run_Rule 
End If
  
If Item.Subject = "Disable Rule" Then
 Disable_Run_Rule 
End If
  
End Sub
  
  
' Macro to enable a rule 
Sub Enable_Run_Rule() 
Dim olRules As Outlook.Rules 
Dim olRule As Outlook.Rule 
Dim intCount As Integer
Dim blnExecute As Boolean
   
    Set olRules = Application.Session.DefaultStore.GetRules 
    Set olRule = olRules.Item("Your Rule Name") 
    olRule.Enabled = True
    If blnExecute Then olRule.Execute ShowProgress:=True
     olRules.Save 
    
    Set olRules = Nothing
    Set olRule = Nothing
End Sub
  
' Macro to disable a rule 
Sub Disable_Run_Rule() 
Dim olRules As Outlook.Rules 
Dim olRule As Outlook.Rule 
Dim intCount As Integer
Dim blnExecute As Boolean
   
    Set olRules = Application.Session.DefaultStore.GetRules 
    Set olRule = olRules.Item("Your Rule Name") 
    olRule.Enabled = False
    If blnExecute Then olRule.Execute ShowProgress:=True
       olRules.Save 
    
    Set olRules = Nothing
    Set olRule = Nothing
End Sub

Trường hợp muốn thiết lập cho nhiều Rule cùng lúc
Chúng ta có thể áp dụng cho nhiều Rule, tuy nhiên trong trường hợp này phải chỉ định (assign) Rule cho Categories đặt tên là "Enable Rule" hoặc "Disable Rule" cho từng Task.

Private Sub Application_Reminder(ByVal Item As Object) 
Dim strRule As String
  
If Item.MessageClass <> "IPM.Task" Then
  Exit Sub
End If
  
strRule = Item.Subject 
  
If Item.Categories = "Enable Rule" Then
Run_Rule strRule, 1 
End If
  
If Item.Categories = "Disable Rule" Then
Run_Rule strRule, 0 
End If
  
End Sub
  
Function Run_Rule(rule_name As String, tf As Boolean) As Boolean
Dim olRules As Outlook.Rules 
Dim olRule As Outlook.Rule 
Dim blnExecute As Boolean
  
    Set olRules = Application.Session.DefaultStore.GetRules 
    Set olRule = olRules.Item(rule_name) 
      
    olRule.Enabled = tf 
      
    If blnExecute Then olRule.Execute ShowProgress:=True
     olRules.Save 
    
    Set olRules = Nothing
    Set olRule = Nothing
End Function

Nguồn: http://www.slipstick.com/developer/enable-or-disable-rule-using-reminder-and-vba/
Read More »

Friday, September 21, 2012

Outlook Mail Merge add Attachment, CC, BCC by VB Script

(Anhgolden's Blog)-Mặc định trong Mail Merge của Outlook không cho phép đính kèm file và bổ sung phần CC và BCC. Tôi xin chia sẻ dùng VB Script để bổ sung 2 tính năng này.

Bước 1: Để Outlook ở chế độ Work Offline (Outlook Menu File - Work Offline). Mục đích các email sau khi hoàn tất sẽ nằm tại "Outbox" và chỉ khi nào ta chủ động Click "Send and Receive" thì email mới được gửi.

Bước 2: Double click vào file VB Script tương ứng:
Outlook-Mail-Merge-add-Attachment.vbs
Outlook-Mail-Merge-add-CC-and-BCC.vbs

' Outlook Mail Merge Attachment
' 
'
SubOutlookMailMergeAttachment

Sub SubOutlookMailMergeAttachment		
	' Script version
	strProgamName = "Outlook Mail Merge add C/C and BCC"
	strProgamVersion = "Outlook Mail Merge add C/C and BCC"	
	
	' Set manual line-breaks in message box texts for windoes versions < 6.
	strBoxCr = vbCrLf
	On Error Resume Next
	Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") 	
	For each System in SystemSet 				
		If System.Version >= 6 Then		
			strBoxCr = ""
		End If
		sWindowsVersion = System.Caption
	Next 
	On Error Goto 0
        
    ' Outlook and Word Constants
    intFolderOutbox = 4
    msoFileDialogOpen = 1
    
    
    ' Load requied objects
    Set WshShell = WScript.CreateObject("WScript.Shell")	' Windows Shell
    Set ObjWord = CreateObject("Word.Application")      ' File Open dialog    
    Set ObjOlApp = CreateObject("Outlook.Application")      ' Outlook
    Set ns = ObjOlApp.GetNamespace("MAPI")                  ' Outlook
    Set box = ns.GetDefaultFolder(intFolderOutbox)          ' Outlook                  	    
         
    ' Check if we can detect problems in the outlook configuration
    sProblems = ""    
    sBuild = Left(ObjOlApp.Version, InStr(1, ObjOlApp.Version, ".") + 1)
    
    ' check spelling check just before sending
    On Error Resume Next
    r = WshShell.RegRead("HKCU\Software\Microsoft\Office\" & sBuild & "\Outlook\Options\Spelling\Check")    
    If Not(Err) And (r = 1) Then
    	sProblems = sProblems & _    	
    	"Your Outlook spell check is configured such that it gives a pop-up box when sending emails. Please disable " & strBoxCr & _
    	"the 'Always check spelling before sending' option in your Outlook. (ErrorCode = 101)" & vbCrLf &vbCrLf
    End If
    On Error Goto 0
    
	' For outlook 2000, 2002, 2003
	If sBuild = "9.0" Or sBuild = "10.0" Or sBuild = "11.0" Then
	
	    ' Check for word as email editor.
	    On Error Resume Next
		intEditorPrefs = WshShell.RegRead("HKCU\Software\Microsoft\Office\" & sBuild & "\Outlook\Options\Mail\EditorPreference")		
		If Not(Err) Then
			If intEditorPrefs = 131073 Or intEditorPrefs = 196609 Or intEditorPrefs = 65537 Then
				' HTML = 131072, HTML & Word To Edit = 131073, Rich Text = 196610, Rich Text & Word To Edit = 196609, Plain Text = 65536, Plain Text & Word To Edit = 65537			
				sProblems = sProblems & _			
				"Your Outlook is configured to use Word as email editor. Please change this to the internal outlook editor in " & strBoxCr & _
				"your outlook settings. (ErrorCode = 102)" & vbCrLf &vbCrLf				
			End If
		End If		
		On Error Goto 0
	End If

	If sProblems <> "" Then				    
		sProblems = "The OMMA scirpt detected settings in your Outlook settings that need to be changed for the software to work." & vbCrLf & vbCrLf & sProblems
		MsgBox 	sProblems, vbExclamation, strProgamName			
		'fout
		Exit Sub
	End If

        
    ' Check if there are messages
    If box.Items.Count = 0 Then
        MsgBox "There are no messages in the Outbox.", vbExclamation, strProgamName           
       	' fout
       Exit Sub
    End If
    
    ' Give a warning if there already is an ment
    If box.Items(1).Attachments.Count > 0 Then
        If MsgBox("The first email in your outbox has already " & box.Items(1).Attachments.Count & " attatchment(s). Do you want to continue?", vbOKCancel + vbQuestion, strProgamName) = vbCancel Then
            ' fout  
		    Exit Sub            
        End If
    End If
        
    
        
    ' Ask user to open a file
    ' Select the attachment filename 

    WScript.Sleep(800)
            
    '''''''''''''''''''''''''''''''''''''''''''''''
    ' Modify for CC and BCC
    '''''''''''''''''''''''''''''''''''''''''''''''    
    		
    For Each Item In box.Items  
		'Item.Recipients.Add("abc@mail.com")
		Item.Cc = "abc@mail.com" 'Bo dung ds email cach nhau bang dau;
		Item.Bcc = "xyz@mail.com" 'Bo dung ds email cach nhau bang dau;
        'Item.Attachments.Add(FileName)                
        Item.Save
    Next 

	
 	'''''''''''''''''''''''''''''''''''''''''''''''
 	' Send the emails using keystrokes
 	'''''''''''''''''''''''''''''''''''''''''''''''
 	
    For i = 1 to box.Items.Count
        
        ' Open email
        Set objItem = box.Items(i)
		Set objInspector = objItem.GetInspector
		objInspector.Activate		
		WshShell.AppActivate(objInspector.Caption)		
		objInspector.Activate
	
		' wait upto 10 seconds until the window has focus		
		okEscape = False
		For j = 1 To 100
			WScript.Sleep(100)
			If (objInspector Is ObjOlApp.ActiveWindow) Then
				okEscape = True
				Exit For
			End	If
		Next
		If Not(okEscape) Then			        		
	        MsgBox "Internal error while opening email in outbox. Please read the how-to and the troubleshooting sections in the " & strBoxCr & "documentation. (ErrorCode = 103)", vbError, strProgamName
	       ' fout
	       Exit Sub			
		End If
		
		' send te email by typing ALT+S
		WshShell.SendKeys("%S")
						
		' wait upto 10 seconds for the sending to complete
		okEscape = False
		For j = 1 To 100
			WScript.Sleep(100)
			boolSent = False
			On Error Resume Next
			boolSent = objItem.Sent
			If Err Then
				boolSent = True
			End	If
			On Error Goto 0
			If boolSent Then
				okEscape = True
				Exit For
			End	If
		Next						
		If Not(okEscape) Then					
			' Error			       
	        MsgBox "Internal error while sending email. Perhaps the email window was not activated. Please read the how-to and " & strBoxCr & "the troubleshooting sections in the documentation. (ErrorCode = 104)", vbExclamation, strProgamName
	       ' fout
	       Exit Sub						
		End If
		
		
	
    Next 

End Sub

Lưu ý:

Trong file Outlook-Mail-Merge-add-CC-and-BCC.vbs, nên sửa lại phần sau theo nhu cầu:
    For Each Item In box.Items
'Item.Recipients.Add("abc@mail.com")
Item.Cc = "abc@mail.com" 'Bo dung ds email cach nhau bang dau;
Item.Bcc = "xyz@mail.com" 'Bo dung ds email cach nhau bang dau;
        'Item.Attachments.Add(FileName)              
        Item.Save
    Next

Chương trình sẽ bổ sung phần Attachment và CC, BCC vào các email đang nằm trong "Outbox" (ở bước 1)

Bước 3: Chính thức Click "Send and Receive" và chuyển lại chế độ Work Online theo nhu cầu.
Read More »