Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Which_Account_Number()
- 'Don't forget to set a reference to Outlook in the VBA editor
- Dim OutApp As Outlook.Application
- Dim I As Long
- Set OutApp = CreateObject("Outlook.Application")
- For I = 1 To OutApp.Session.Accounts.Count
- MsgBox OutApp.Session.Accounts.Item(I) & " : This is account number " & I
- Next I
- End Sub
- Sub Mail_small_Text_Change_Account()
- 'Only working in Office 2007-2016
- 'Don't forget to set a reference to Outlook in the VBA editor
- Dim OutApp As Outlook.Application
- Dim OutMail As Outlook.MailItem
- Dim strbody As String
- Set OutApp = CreateObject("Outlook.Application")
- Set OutMail = OutApp.CreateItem(olMailItem)
- strbody = "Hi there" & vbNewLine & vbNewLine & _
- "This is line 1" & vbNewLine & _
- "This is line 2" & vbNewLine & _
- "This is line 3" & vbNewLine & _
- "This is line 4"
- On Error Resume Next
- With OutMail
- .To = "ron@debruin.nl"
- .CC = ""
- .BCC = ""
- .Subject = "This is the Subject line"
- .Body = strbody
- 'SendUsingAccount is new in Office 2007
- 'Change Item(1)to the account number that you want to use
- .SendUsingAccount = OutApp.Session.Accounts.Item(1)
- .Send 'or use .Display
- End With
- On Error GoTo 0
- Set OutMail = Nothing
- Set OutApp = Nothing
- End Sub
Add Comment
Please, Sign In to add comment