AHK:StringReplace名称到电子邮件

时间:2018-03-21 17:50:05

标签: autohotkey

我创建了一个模板,用于向我创建的新用户的客户发送电子邮件。

当前代码可以删除空格并添加句点。例如: John Smith 将变为 John.Smith@test.com

StringReplace, UserID, UserID, %A_SPACE%, . , All

我想创建一个脚本来删除空格和字母,直到第一个字母创建 JSmith@test.com

这是我当前的脚本:

InputBox, ClientE, Client Name, Please type the name of Company

if ClientE = test
{
    EmailE = test.com
}

if (A_hour >= 12) {
    InputBox, UserID, User's Name, Please type the user's name
    InputBox, PASSWE, Password, Please type the password
    sleep, 700
    Send, Good Afternoon ,{Enter 2}This e-mail is to inform you that the requested new user account for{space}
    Send, ^b
    Send, %UserID%
    Send, ^b
    Send, {space}has been created as follows;{ENTER 2}

    StringReplace, UserID, UserID, %A_SPACE%, . , All

    Send, Desktop user name = %UserID% {ENTER}E-mail address = %UserID%@%EmailE%{SPACE} {ENTER}Password = {SPACE}{ENTER 2}Please let me know if you need anything further.{ENTER 2}Best regards,{ENTER 2}Garrett Haggard
}
else  
{
    InputBox, UserID, User's Name, Please type which user
    sleep, 700
    Send, Good Morning ,{Enter 2}This e-mail is to inform you that the requested new user account for{space}
    Send, ^b
    Send, %UserID%
    Send, ^b
    Send, {space}has been created as follows;{ENTER 2}

    StringReplace, UserID, UserID, %A_SPACE%, . , All

    Send, Desktop user name = 
    Send, ^b
    Send, %UserID%
    Send, ^b
    Send, {ENTER}E-mail address = %UserID%@%EmailE%{SPACE} {ENTER}Password = 
    Send, ^b
    Send, %PASSWE%
    Send, ^b
    Send, {SPACE}{ENTER 2}Please let me know if you need anything further.{ENTER 2}Best regards,{ENTER 2}
}
return

2 个答案:

答案 0 :(得分:1)

UserID := "John Smith"
stringSplit, user_first_last, UserID, %A_Space%
StringLeft, first_initial, user_first_last1, 1
email := first_initial . user_first_last2 . "@test.com"
msgbox, %email%
return

答案 1 :(得分:0)

以下是包含更新/附加scrit的代码

    {
    if (A_hour >=12)
    {
        RTYH = Good Afternoon
    }
        Else
        {
        RTYH = Good Morning     
    }

InputBox, ClientE, Client Name, Please type the name of Company
 InputBox, UserID, User's Name, Please type the user's name
 ;InputBox, PASSWE, Password, Please type the password
 sleep, 700
  Send, %RTYH% ,{Enter 2}This e-mail is to inform you that the requested new user account for{space}
 Send, ^b
Send, %UserID%
Send, ^b
Send, {space}has been created as follows;{ENTER 2}


if ClientE = test
 {
      UserID := UserID
stringSplit, user_first_last, UserID, %A_Space%
StringLeft, first_initial, user_first_last1, 1
UserID4 := first_initial . user_first_last2 
UserID5 := first_initial . user_first_last2 . "@test.com"
 }
if ClientE = testing
{
       UserID := UserID
stringSplit, user_first_last, UserID, %A_Space%
StringReplace, UserID4, UserID, %A_SPACE%, . , All
UserID4 := UserID4
UserID5 := UserID4 . "@testing.com"
}

 Send, Desktop user name = 
 Send, ^b
 Send, %UserID4% 
 Send, ^b
 Send, {ENTER}E-mail address = %UserID5%{SPACE} {ENTER}Password ={SPACE}{ENTER 2}Please let me know if you need anything further.{ENTER 2}Best regards,{ENTER 2}
}
return