0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Outlookにメールアカウントを自動追加する方法(PRFファイル活用)

Last updated at Posted at 2025-05-23

PRFを利用してOutlookにメールアカウントを自動追加する方法

🔰 はじめに

お仕事で数百台のPCにメールアカウントを自動追加したいときありますよね?(ない)、手動で設定するのは手間がかかります。この記事では、PRFファイルを使って、OutlookにPOP3アカウントを自動追加する方法を紹介します。ちなみに、Chatgpt等のAIに聞いても、くそみたいな出力しか出なかったので、この記事を書いています。

  • 対応バージョン:Outlook(classic)
  • 対象:POP3アカウント
  • PRFファイルでアカウント定義
  • バッチ or PowerShellで自動反映

準備するもの

  • 追加したいメールアカウント
  • 受信サーバ pop.XXX.XXX
  • 送信サーバ smtp.XXX.XXX
  • メールサーバのパスワード

📦 PRFファイルとは?

PRF(Outlook Profile)ファイルは、Outlookのユーザープロファイルを一括で構成する設定ファイルです。ただし、パスワードはPRFファイルで読み込まれないようになっています。(セキュリティ面の関係かな?)

以下のような情報を一括定義可能です:

  • アカウント情報(メールアドレス・サーバー)
  • PSTファイルの保存場所
  • メール送受信設定

🧾 PRFファイルのサンプル

以下はPRFファイル(mailsetup.prf)の具体例です:

;Automatically generated PRF file from the Microsoft Office Customization and Installation Wizard

; **************************************************************
; Section 1 - Profile Defaults
; **************************************************************

[General]
Custom=1
ProfileName=testing
DefaultProfile=Yes
OverwriteProfile=Append
ModifyDefaultProfileIfPresent=FALSE
DefaultStore=Service3

; **************************************************************
; Section 2 - Services in Profile
; **************************************************************

[Service List]
;ServiceX=Microsoft Outlook Client
Service1=Microsoft Outlook Client
Service2=Internet Mail
Service3=Unicode Personal Folders

;***************************************************************
; Section 3 - List of internet accounts
;***************************************************************

[Internet Account List]
Account1=I_Mail

;***************************************************************
; Section 4 - Default values for each service.
;***************************************************************

[Service3]
UniqueService=No
Name=メールアドレス
PathToPersonalFolders=%USERPROFILE%\Documents\Outlook\***.pst
EncryptionType=0x80000000


;***************************************************************
; Section 5 - Values for each internet account.
;***************************************************************

[Account1]
UniqueService=Yes
AccountName=メールアドレス(任意)
POP3Server=pop.XXX.XXX
SMTPServer=smtp.XXX.XXX
POP3UserName=メールアドレス
EmailAddress=メールアドレス
POP3UseSPA=0
DisplayName=
ReplyEMailAddress=
SMTPUseAuth=1
SMTPAuthMethod=0
ConnectionType=0
LeaveOnServer=0x70001
ConnectionOID=MyConnection
POP3Port=110
POP3UseSSL=0
ServerTimeOut=60
SMTPPort=587
SMTPUseSSL=1

;***************************************************************
; Section 6 - Mapping for profile properties
;***************************************************************

[Microsoft Exchange Server]
ServiceName=MSEMS
MDBGUID=5494A1C0297F101BA58708002B2A2517
MailboxName=PT_STRING8,0x6607
HomeServer=PT_STRING8,0x6608
OfflineAddressBookPath=PT_STRING8,0x660E
OfflineFolderPath=PT_STRING8,0x6610

[Exchange Global Section]
SectionGUID=13dbb0c8aa05101a9bb000aa002fc45a
MailboxName=PT_STRING8,0x6607
HomeServer=PT_STRING8,0x6608
RPCoverHTTPflags=PT_LONG,0x6623
RPCProxyServer=PT_UNICODE,0x6622
RPCProxyPrincipalName=PT_UNICODE,0x6625
RPCProxyAuthScheme=PT_LONG,0x6627
CachedExchangeConfigFlags=PT_LONG,0x6629

[Microsoft Mail]
ServiceName=MSFS
ServerPath=PT_STRING8,0x6600
Mailbox=PT_STRING8,0x6601
Password=PT_STRING8,0x67f0
RememberPassword=PT_BOOLEAN,0x6606
ConnectionType=PT_LONG,0x6603
UseSessionLog=PT_BOOLEAN,0x6604
SessionLogPath=PT_STRING8,0x6605
EnableUpload=PT_BOOLEAN,0x6620
EnableDownload=PT_BOOLEAN,0x6621
UploadMask=PT_LONG,0x6622
NetBiosNotification=PT_BOOLEAN,0x6623
NewMailPollInterval=PT_STRING8,0x6624
DisplayGalOnly=PT_BOOLEAN,0x6625
UseHeadersOnLAN=PT_BOOLEAN,0x6630
UseLocalAdressBookOnLAN=PT_BOOLEAN,0x6631
UseExternalToHelpDeliverOnLAN=PT_BOOLEAN,0x6632
UseHeadersOnRAS=PT_BOOLEAN,0x6640
UseLocalAdressBookOnRAS=PT_BOOLEAN,0x6641
UseExternalToHelpDeliverOnRAS=PT_BOOLEAN,0x6639
ConnectOnStartup=PT_BOOLEAN,0x6642
DisconnectAfterRetrieveHeaders=PT_BOOLEAN,0x6643
DisconnectAfterRetrieveMail=PT_BOOLEAN,0x6644
DisconnectOnExit=PT_BOOLEAN,0x6645
DefaultDialupConnectionName=PT_STRING8,0x6646
DialupRetryCount=PT_STRING8,0x6648
DialupRetryDelay=PT_STRING8,0x6649

[Personal Folders]
ServiceName=MSPST MS
Name=PT_STRING8,0x3001
PathToPersonalFolders=PT_STRING8,0x6700 
RememberPassword=PT_BOOLEAN,0x6701
EncryptionType=PT_LONG,0x6702
Password=PT_STRING8,0x6703

[Unicode Personal Folders]
ServiceName=MSUPST MS
Name=PT_UNICODE,0x3001
PathToPersonalFolders=PT_STRING8,0x6700 
RememberPassword=PT_BOOLEAN,0x6701
EncryptionType=PT_LONG,0x6702
Password=PT_STRING8,0x6703

[Outlook Address Book]
ServiceName=CONTAB

[LDAP Directory]
ServiceName=EMABLT
ServerName=PT_STRING8,0x6600
UserName=PT_STRING8,0x6602
UseSSL=PT_BOOLEAN,0x6613
UseSPA=PT_BOOLEAN,0x6615
DisableVLV=PT_LONG,0x6616
DisplayName=PT_STRING8,0x3001
ConnectionPort=PT_STRING8,0x6601
SearchTimeout=PT_STRING8,0x6607
MaxEntriesReturned=PT_STRING8,0x6608
SearchBase=PT_STRING8,0x6603

[Microsoft Outlook Client]
SectionGUID=0a0d020000000000c000000000000046
FormDirectoryPage=PT_STRING8,0x0270
WebServicesLocation=PT_STRING8,0x0271
ComposeWithWebServices=PT_BOOLEAN,0x0272
PromptWhenUsingWebServices=PT_BOOLEAN,0x0273
OpenWithWebServices=PT_BOOLEAN,0x0274
CachedExchangeMode=PT_LONG,0x041f
CachedExchangeSlowDetect=PT_BOOLEAN,0x0420

[Personal Address Book]
ServiceName=MSPST AB
NameOfPAB=PT_STRING8,0x001e3001
Path=PT_STRING8,0x001e6600
ShowNamesBy=PT_LONG,0x00036601

; ************************************************************************
; Section 7 - Mapping for internet account properties.  DO NOT MODIFY.
; ************************************************************************

[I_Mail]
AccountType=POP3
;--- POP3 Account Settings ---
AccountName=PT_UNICODE,0x0002
DisplayName=PT_UNICODE,0x000B
EmailAddress=PT_UNICODE,0x000C
;--- POP3 Account Settings ---
POP3Server=PT_UNICODE,0x0100
POP3UserName=PT_UNICODE,0x0101
POP3UseSPA=PT_LONG,0x0108
Organization=PT_UNICODE,0x0107
ReplyEmailAddress=PT_UNICODE,0x0103
POP3Port=PT_LONG,0x0104
POP3UseSSL=PT_LONG,0x0105
; --- SMTP Account Settings ---
SMTPServer=PT_UNICODE,0x0200
SMTPUseAuth=PT_LONG,0x0203
SMTPAuthMethod=PT_LONG,0x0208
SMTPUserName=PT_UNICODE,0x0204
SMTPUseSPA=PT_LONG,0x0207
ConnectionType=PT_LONG,0x000F
ConnectionOID=PT_UNICODE,0x0010
SMTPPort=PT_LONG,0x0201
SMTPUseSSL=PT_LONG,0x0202
ServerTimeOut=PT_LONG,0x0209
LeaveOnServer=PT_LONG,0x1000

[IMAP_I_Mail]
AccountType=IMAP
;--- IMAP Account Settings ---
AccountName=PT_UNICODE,0x0002
DisplayName=PT_UNICODE,0x000B
EmailAddress=PT_UNICODE,0x000C
;--- IMAP Account Settings ---
IMAPServer=PT_UNICODE,0x0100
IMAPUserName=PT_UNICODE,0x0101
IMAPUseSPA=PT_LONG,0x0108
Organization=PT_UNICODE,0x0107
ReplyEmailAddress=PT_UNICODE,0x0103
IMAPPort=PT_LONG,0x0104
IMAPUseSSL=PT_LONG,0x0105
; --- SMTP Account Settings ---
SMTPServer=PT_UNICODE,0x0200
SMTPUseAuth=PT_LONG,0x0203
SMTPAuthMethod=PT_LONG,0x0208
SMTPUserName=PT_UNICODE,0x0204
SMTPUseSPA=PT_LONG,0x0207
ConnectionType=PT_LONG,0x000F
ConnectionOID=PT_UNICODE,0x0010
SMTPPort=PT_LONG,0x0201
SMTPUseSSL=PT_LONG,0x0202
ServerTimeOut=PT_LONG,0x0209
CheckNewImap=PT_LONG,0x1100
RootFolder=PT_UNICODE,0x1101

[INET_HTTP]
AccountType=HOTMAIL
Account=PT_UNICODE,0x0002
HttpServer=PT_UNICODE,0x0100
UserName=PT_UNICODE,0x0101
Organization=PT_UNICODE,0x0107
UseSPA=PT_LONG,0x0108
TimeOut=PT_LONG,0x0209
Reply=PT_UNICODE,0x0103
EmailAddress=PT_UNICODE,0x000C
FullName=PT_UNICODE,0x000B
Connection Type=PT_LONG,0x000F
ConnectOID=PT_UNICODE,0x0010
  • Name、PathToPersonalFoldersは、参照したいpstファイルの場所
  • AccountNameは、好きなもんにして
  • POP3Serverは、受信サーバ
  • SMTPServerは、送信サーバ
  • EmailAddressは、メールアドレス

いろんなパラメータがあるけど、詳しい資料はどこを探しても見当たらなかったので実験しながらパラメータの意味を推測していく感じです。

それっぽいけど、全然参考にならない資料を添付しておきます。
https://download.microsoft.com/download/d/9/b/d9b5e9dd-c681-4430-a858-3427808677c1/PRFwhitepaper.doc

実行方法

①コマンドプロンプトの場合

> Outlookの実行ファイルのパス /importprf PRFのパス

②PowerShellの場合

***.ps1
# PRFファイルのパス(現在の場所にあるpop.prfファイルを使用)
$prfPath = Join-Path -Path $PSScriptRoot -ChildPath "pop.PRF"

# PRFファイルが存在するか確認
if (-not (Test-Path $prfPath)) {
    Write-Error "not found ($prfPath)"
    exit 1
}

# Outlookが起動しているか確認し、起動している場合は終了させる
$outlookProcess = Get-Process -Name "OUTLOOK" -ErrorAction SilentlyContinue
if ($null -ne $outlookProcess) {
    Write-Host "close outlook..."
    $outlookProcess | ForEach-Object { $_.CloseMainWindow() | Out-Null }
    Start-Sleep -Seconds 2
    $outlookProcess | Where-Object { !$_.HasExited } | Stop-Process -Force
}

# Outlookを起動し、PRFファイルをインポート
Write-Host "import prf file..."
Start-Process -FilePath "OUTLOOK.EXE" -ArgumentList "/importprf `"$prfPath`""

Write-Host "finish." 

PRFファイルとPowerShellのスクリプトファイルを同じフォルダに入れる。
PowerShellのスクリプトファイルを右クリックして、PowerShellで実行する。

以上、なかなかマニアックな記事だけど誰かの役に立ちますように!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?