2016-07-26 14 views
2

在EMAIL中使用帶EM_ *指令的以下代碼時,我應該在電子郵件地址前使用outlook(我使用Outlook 2010)中的別名「XYZ」,並且在收件箱視圖中只使用別名。 Outlook收到的電子郵件沒有別名。如何使用EM_SENDER和EM_FROM指令將電子郵件別名命名爲SAS?

Filename MAILBOX email CT="text/html" ; 
Data _null_ ; 
    length HTML_DirLine $ 2048 ; 

    fid = fopen('MAILBOX','O'); 

    /* write the TO email address */ 
    HTML_DirLine = '!EM_TO! ("[email protected]")' ; 
    fputrc1 = fput(fid,trim(HTML_DirLine)); 
    rc = fwrite(fid); 

    /* write the FROM email address */ 
    HTML_DirLine = '!EM_FROM! (" XYZ <[email protected]>")' ; 
    fputrc1 = fput(fid,trim(HTML_DirLine)); 
    rc = fwrite(fid); 

    /* write the SENDER email address */ 
    HTML_DirLine = '!EM_SENDER! (" XYZ <[email protected]>")' ; 
    fputrc1 = fput(fid,trim(HTML_DirLine)); 
    rc = fwrite(fid); 

    /* write the Subject email address */ 
    HTML_DirLine = '!EM_SUBJECT! Test Email ' ; 
    fputrc1 = fput(fid,trim(HTML_DirLine)); 
    rc = fwrite(fid); 

    /* write the Body of email message */ 
    HTML_DirLine = 'This is the test email. Pls ignore.' ; 
    fputrc1 = fput(fid,trim(HTML_DirLine)); 
    rc = fwrite(fid); 

    /* Send the email message */ 
    HTML_DirLine = '!EM_SEND!' ; 
    fputrc1 = fput(fid,trim(HTML_DirLine)); 
    rc = fclose(fid); 

run ; 

但是,當我沒有指令使用它工作正常。以下是代碼,

Filename mailbox EMAIL ; 
Data _null_ ; 
File mailbox TO='[email protected]' 
     Subject='Test Email message' 
    from='XYZ <[email protected]>' 
    sender='XYZ <[email protected]>' ; 
put "Hi There," 
put "Please ignore this test email" ; 
run ; 

有關如何使別名正確顯示使用SAS中的指令的任何建議?由於

回答

1

這些都是我從你的兩個測試電子郵件獲取(如Mozilla Thunderbird中查看)標題:

使用指令:

Delivered-To: [email protected] 
Received: by 10.200.49.247 with SMTP id i52csp1678880qte; 
     Tue, 26 Jul 2016 00:47:07 -0700 (PDT) 
X-Received: by 10.194.5.230 with SMTP id v6mr21227765wjv.92.1469519227576; 
     Tue, 26 Jul 2016 00:47:07 -0700 (PDT) 
Return-Path: <[email protected]> 
Received: from localhost.localdomain (host217-39-41-194.range217-39.btcentralplus.com. [217.39.41.194]) 
     by mx.google.com with ESMTP id dq8si18546922wjb.285.2016.07.26.00.47.06 
     for <[email protected]>; 
     Tue, 26 Jul 2016 00:47:07 -0700 (PDT) 
Received-SPF: softfail (google.com: domain of transitioning [email protected] does not designate 217.39.41.194 as permitted sender) client-ip=217.39.41.194; 
Authentication-Results: mx.google.com; 
     spf=softfail (google.com: domain of transitioning [email protected] does not designate 217.39.41.194 as permitted sender) [email protected] 
Received: from localhost (localhost [IPv6:::1]) 
    by localhost.localdomain (Postfix) with SMTP id 38ACD226E8 
    for <[email protected]>; Tue, 26 Jul 2016 07:47:11 +0000 (UTC) 
Date: 26 Jul 2016 07:47:11 -0000 
Subject: =?utf-8?B?VGVzdCBFbWFpbA==?= 
From: " XYZ <[email protected]>"@localhost.localdomain 
Sender: (" XYZ <[email protected]>") 
To: [email protected] 
X-Mailer: 9.04.01M3P062415 
MIME-Version: 1.0 
Content-Type: text/html; 
     charset=utf-8 
Content-Transfer-Encoding: base64 
Message-Id: <[email protected]> 

VGhpcyBpcyB0aGUgdGVzdCBlbWFpbC4gUGxzIGlnbm9yZS4= 

無指令:

Delivered-To: [email protected] 
Received: by 10.200.49.247 with SMTP id i52csp1677118qte; 
     Tue, 26 Jul 2016 00:42:39 -0700 (PDT) 
X-Received: by 10.28.238.154 with SMTP id j26mr47226158wmi.94.1469518959773; 
     Tue, 26 Jul 2016 00:42:39 -0700 (PDT) 
Return-Path: <[email protected]> 
Received: from localhost.localdomain (host217-39-41-194.range217-39.btcentralplus.com. [217.39.41.194]) 
     by mx.google.com with ESMTP id v2si18549245wjh.115.2016.07.26.00.42.39 
     for <[email protected]>; 
     Tue, 26 Jul 2016 00:42:39 -0700 (PDT) 
Received-SPF: softfail (google.com: domain of transitioning [email protected] does not designate 217.39.41.194 as permitted sender) client-ip=217.39.41.194; 
Authentication-Results: mx.google.com; 
     spf=softfail (google.com: domain of transitioning [email protected] does not designate 217.39.41.194 as permitted sender) [email protected]; 
     dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 
Received: from localhost (localhost [IPv6:::1]) 
    by localhost.localdomain (Postfix) with SMTP id 78EA7226F2 
    for <[email protected]>; Tue, 26 Jul 2016 07:42:44 +0000 (UTC) 
Date: 26 Jul 2016 07:42:44 -0000 
Subject: =?utf-8?B?VGVzdCBFbWFpbCBtZXNzYWdl?= 
From: XYZ <[email protected]> 
Sender: XYZ <[email protected]> 
To: [email protected] 
X-Mailer: 9.04.01M3P062415 
MIME-Version: 1.0 
Content-Type: text/plain; 
     charset=utf-8 
Content-Transfer-Encoding: base64 
Message-Id: <[email protected]> 

SGkgVGhlcmUsClBsZWFzZSBpZ25vcmUgdGhpcyB0ZXN0IGVtYWls 

這些都有一個發件人標題,但是在使用這些指令時,你似乎已經選取了一組額外的括號。我將相應的行更改爲:

HTML_DirLine = '!EM_SENDER! "XYZ <[email protected]>"' ; 

而且似乎解決了這個問題,以便生成相同的輸出。如果發送郵件的服務器沒有列在原始域的MX記錄中,即使發件人標題填充正確,您仍可能發現電子郵件客戶端不會顯示發件人。

順便說一下,爲什麼你在代碼中使用fopen/fput等所有的指令? put聲明在這裏更簡單,應該也一樣。

+0

謝謝。有效。我的代碼的問題是圓括號之間的空格。當我開始向後推薦您的建議並添加括號時,我的代碼也起作用了。 'code' HTML_DirLine ='!EM_FROM! (「XYZ <[email protected]>」)'; HTML_DirLine ='!EM_SENDER! (「XYZ <[email protected]>」)';'代碼' – user4288151