I have created a template for send out emails to clients of the new user I have created.
The current code have it to remove the space and add a period. For Example: John Smith will be turned into John.Smith#test.com
StringReplace, UserID, UserID, %A_SPACE%, . , All
I would like to create a script to remove the space and letters up to the first letter creating JSmith#test.com
Here is the current script I have:
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
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
Here is the code with the updated/additional 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
Related
I have MsAccess Form:
ClientName, ID fields - records filled with the information
Gender, Race, PrimaryLanguage fields (combo box type) are empty records
Users will fill Gender, Race and PrimaryLanguage, PrimaryDisability fields with the information.
My goal is - before user will move to the next record, I want he to be unable to proceed until those fields (Gender / Race) are filled with its content.
The problem is - Gender / Race / PrimaryLanguage, PrimaryDisability for the existing clients have to stay empty, but at the same time - when user starts filling it, it needs to be filled mandatory.
It works this way only in case if I am adding a new record.
(I have Gender / Race fields as required) - but doesn't work with the existing records.
PS - the answer provided below is great, but worked on my end for 2 fields only
What about 3 or more fields?
I had idea of adding the event procedure to each button in the Form, not to
the whole Form.
code should be something like:
Private Sub Gender_BeforeUpdate(Cancel As Integer)
If Nz(Me.Gender, "") = "" And (Nz(Me.Race, "") <> ""
Or (Nz(Me. PrimaryLanguage, "") <> ""
Or (Nz(Me. PrimaryDisability, "") <> "")
Then
MsgBox "Select Gender", vbInformation
Cancel = True
End If
End Sub
But it says about syntax mistakes
Please help!
Use BeforeUpdate event to cancel updating of a record before moving to another record
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(Me.ClientName, "") <> "" And Nz(Me.Gender, "") = "" And Nz(Me.Race, "") = "" And Nz(Me.PrimaryLanguage, "") = "" And Nz(Me.PrimaryDisability, "") = "" Then
Exit Sub
End If
If Nz(Me.Gender, "") = "" Then
MsgBox "Select Gender", vbInformation
Cancel = True
Exit Sub
End If
If Nz(Me.Race, "") = "" Then
MsgBox "Select Race", vbInformation
Cancel = True
Exit Sub
End If
If Nz(Me.PrimaryLanguage, "") = "" Then
MsgBox "Enter PrimaryLanguage", vbInformation
Cancel = True
Exit Sub
End If
If Nz(Me.PrimaryDisability, "") = "" Then
MsgBox "Enter PrimaryDisability ", vbInformation
Cancel = True
Exit Sub
End If
End Sub
I have an autohotkey script that search if specific window exists, if so, it will activate it.
I want that it will search only in the current desktop (I'm using Windows 10).
Do you have a suggestion how to do it?
My Script:
#c::
IfWinExist ,ahk_class ConsoleWindowClass
{
ifWinActive
WinActivatebottom ,ahk_class ConsoleWindowClass
else
WinActivate
return
}
#c:: WinActivateBottomOnCurrentVirtualDesktop("ConsoleWindowClass")
WinActivateBottomOnCurrentVirtualDesktop(Class){
IfWinExist, ahk_class %Class%
{
list := ""
LastWin := ""
; get a list of those windows on the current desktop
WinGet, id, list, ahk_class %Class%
Loop, %id%
{
this_ID := id%A_Index%
If IsWindowOnCurrentVirtualDesktop(this_ID)
LastWin := this_ID ; retrieves the bottommost matching window ID
}
WinActivate, ahk_id %LastWin%
}
}
; https://autohotkey.com/boards/viewtopic.php?p=64295#p64295
; Indicates whether the provided window is on the currently active virtual desktop:
IsWindowOnCurrentVirtualDesktop(hWnd) {
onCurrentDesktop := ""
CLSID := "{aa509086-5ca9-4c25-8f95-589d3c07b48a}"
IID := "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}"
IVirtualDesktopManager := ComObjCreate(CLSID, IID)
Error := DllCall(NumGet(NumGet(IVirtualDesktopManager+0), 3*A_PtrSize), "Ptr", IVirtualDesktopManager, "Ptr", hWnd, "IntP", onCurrentDesktop)
ObjRelease(IVirtualDesktopManager)
if !(Error=0)
return false, ErrorLevel := true
return onCurrentDesktop, ErrorLevel := false
}
Thanks in advance :), I am trying to attach the data of subform also in mail body.
Current Status: I am able to attach Main forms data and generate mail but unable to attach subform's data as it only includes the first row, Tryied doing it through Subform and query both but no success. I will prefer to do it by subform itself. Subform's Name is : "subUpdateOrder". VB Code:
Private Sub InformCustomer_Click()
On Error GoTo Err_InformCustomer_Click
Dim CustName As String ' Customer Name
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim DelDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stOrderID As String '-- The Order ID from form
Dim detailQry As String
'Dim stHelpDesk As String '-- Person who assigned ticket
'Dim strSQL As String '-- Create SQL update statement
'Dim errLoop As Error
CstName = Me![CustName]
varTo = Me![CustEmail]
stSubject = ":: Update - Oder Status ::"
stOrderID = Me.[OdrID]
DelDate = Me.[OdrDeliveryDate]
stText = "Dear" & CstName & _
"You have been assigned a new ticket." & Chr$(13) & Chr$(13) & _
"Order Number: " & stOrderID & Chr$(13) & _
"Please refer to your order status " & Chr$(13) & _
"Exp Delevery Date: " & DelDate & Chr$(13) & Chr$(13) & _
dQuery & Chr$(13) & _
"This is an automated message. Please do not respond to this e-mail."
'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, True
Err_InformCustomer_Click:
MsgBox Err.Description
End Sub
Form Img: Form and Command1 button to run the code
It would be something like (to insert before CstName = Me![CustName]):
Dim dQuery As String
Dim rs As DAO.Recordset
Set rs = Me!NameOfYourSubformCONTROL.Form.RecordsetClone
While Not rs.EOF
dQuery = dQuery & rs![Brand Name].Value & vbTab & rs![Model Name].Value & vbTab & rs![Color].Value & vbCrLF
Wend
Set rs = Nothing
I use the following code to get ContactInfo (in Outlook2010) of each recipient of a mail to be sent. The code works, but only for a few contacts, although all contacts are stored in my adressbook. For some the last line (GetContact) delivers Nothing. Why?
' Create RDO session
Dim session
Set session = CreateObject("Redemption.RDOSession")
Set session.MAPIOBJECT = Application.session.MAPIOBJECT
' Get current email
ActiveInspector.CurrentItem.Save ' Necessary to get current status
Dim mail
Set mail = session.GetMessageFromID(ActiveInspector.CurrentItem.EntryID)
' Create salutation line
Dim salutationLine As String
salutationLine = ""
For Each Recipient In mail.Recipients
' Skip CC and BCC addresses
If (Recipient.Type <> olTo) Then GoTo NextRecipient
' Assume standard salutation and use complete name as first name
Dim salutationType As String
salutationType = ""
Dim firstName As String
Dim lastName As String
Dim recipientName As String
recipientName = IIf(Recipient.Name <> "", Recipient.Name, Recipient.Address)
lastName = ""
If InStr(1, recipientName, " ") > 0 Then
firstName = Split(recipientName, " ")(0)
lastName = Split(recipientName, " ")(1)
End If
Dim addressEntry
Set addressEntry = Recipient.addressEntry
If (Not addressEntry Is Nothing) Then
' If we have qualified name information: extract first and last name
If (addressEntry.firstName <> "") Then firstName = addressEntry.firstName
If (addressEntry.lastName <> "") Then lastName = addressEntry.lastName
Dim contactInfo
Set contactInfo = addressEntry.GetContact()
If (Not contactInfo Is Nothing) Then
GetContact in both Outlook Object Model and Redemption relies on the entry id being of OAB type. On the incoming messages, all SMTP recipients have one-off entry id (it does not point to any existing address book objects and embeds name, address and address type inside).
In general, you will need to extract the recipient address, then search the Contacts folder for a matching contact based on email1, email2 or email3 values.
My Code is below.Whenever I try to run it I get an error saying I'm using duplicate hotkeys when in practice they would never interfere with each other. How do I get around this?
"Your post does not have much context to explain the code sections; please explain your scenario more clearly.". So I guess need to explain my code.. It's extremely simple I have a state variable that is changed by pressing the arrow keys, then I have if statements that checks what the state is. If I press numpad1 when state = "up" the script should type "A", if the state = "right" it would print I. However I'm getting an error since I used the same hotkey multiple times in my different if statements.
state := "none"
UP::
state := "up"
Right::
state := "right"
DOWN::
state := "down"
LEFT::
state := "left"
if (state = "up"){
Numpad1::
Send A
Return
Numpad2::
Send B
Return
Numpad3::
Send C
Return
Numpad4::
Send D
Return
Numpad6::
Send E
Return
Numpad7::
Send F
Return
Numpad8::
Send G
Return
Numpad9::
Send H
Return
}
if (sate = "right"){
Numpad1::
Send I
Return
Numpad2::
Send J
Return
Numpad3::
Send K
Return
Numpad4::
Send L
Return
Numpad6::
Send M
Return
Numpad7::
Send N
Return
Numpad8::
Send O
Return
Numpad9::
Send P
Return
}
if (state = "down"){
Numpad1::
Send Q
Return
Numpad2::
Send R
Return
Numpad3::
Send S
Return
Numpad4::
Send T
Return
Numpad6::
Send U
Return
Numpad7::
Send V
Return
Numpad8::
Send W
Return
Numpad9::
Send X
Return
}
if (state = "left"){
Numpad1::
Send Y
Return
Numpad2::
Send Z
Return
}
When you use AHK_L, you can use #IF with multiple definitions of the same hotkey. WARNING this does NOT work with the regular AHK version.
Here is an example.
You set the variables by typing none\ right\ or left\ .
Depending on the variable setting your Tab key will either send NORMAL, LEFT or RIGHT.
#SingleInstance Force
Tab::Send, NORMAL
#if (state = "left")
Tab::Send, LEFT
#if ; End #if (state = "left")
#if (state = "right")
Tab::Send, RIGHT
#if ; End #if (state = "right")
:*:right\::
state := "right"
Return
:*:left\::
state := "left"
Return
:*:none\::
state := "none"
Return
Alternatively, with the normal AHK, you define ONE hotkey and place IF statements inside the hotkeys to change the behaviour based on the state variable.