I'm using VBScript and CDO to send emails from a custom form in Outlook. Basically:
Sub MySendButton_Click()
Set objEmail = CreateObject("CDO.Message")
objEmail.To = "a#a.a; b#b.b; c#c.c"
objEmail.HTMLBody = "<b>hi!</b>"
objEmail.Send()
End Sub
Is it possible to send an email to only "a#a.a" but show all three recipients in the To field on that person's copy? I need this functionality so that the end user can Reply To All, but the other recipients don't need to receive this particular email.
I think ReplyTo is what you need:
objEmail.To = "a#a.a"
objEmail.ReplyTo = "a#a.a; b#b.b; c#c.c"
Related
I need to write a piece of code in the Code Stage in Blue Prism. I am dealing with Outlook and my current object can send out emails in Outlook.
However, what I need to do now is to check if the email addresses in to/cc/bcc are from the same domain (eg. check if all recipients' email addresses end with "#abc.com"). My current piece of code is coded in C#. Does anyone have any idea on how this can be done?
Here is what I have currently:
I have a list of input parameters for fields like "to, from, cc, bcc, ..., abc_recipients_only". All the parameters are in string and the "abc_recipient_only" parameter is in a Boolean form.
The codes I have currently gives me an error saying "Compiler error at line 14: The name "Recipient" does not exist in the current context"".
EmailMessage email = new EmailMessage(service);
to = to.Replace(',',';');
cc = cc.Replace(',',';');
bcc = bcc.Replace(',',';');
foreach(var row in to.Split(';')){
if (abc_recipients_only == true){
if(Recipient.AddressEntry == "abc.com"){
email.ToRecipients.Add(row.Trim());
}
}
else{
if (string.IsNullOrEmpty(row.Trim())) continue;
email.ToRecipients.Add(row.Trim());
}
}
email.SendAndSaveCopy();
The MailItem.Recipients property returns a Recipients collection that represents all the recipients for the Outlook item. So, you can iterate over all items in the collection and check recipient's domains.
Use the Recipients (index) method, where index is the name or index number, to return a single Recipient object. The name can be a string that represents the display name, the alias, the full SMTP email address, or the mobile phone number of the recipient. A good practice is to use the SMTP email address for a mail message, and the mobile phone number for a mobile message.
The Recipient.Address property returns a string representing the email address of the Recipient.
If you meet an exchange-like email address you can use the approach described in the HowTo: Convert Exchange-based email address into SMTP email address article.
Assuming your company is using Exchange, loop through all recipients in the message (MailItem.Recipients collection) and check if each address type is "EX" - Recipient.AddressEntry.Type == "EX" or Recipient.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3002001F") == "EX". The latter is more efficient.
How to get all unread mails from a particular view(eg $Inbox) of lotus notes database using vbscript?
Set objNotesSession = CreateObject("Lotus.NotesSession")
objNotesSession.Initialize(strPassword)
Set objNotesdb = objNotesSession.GETDATABASE(strMailServer,
strMailDBName)
If Not objNotesdb.IsOpen = True Then
Call objNotesdb.Open
End If
Dim view
Dim vec
Set view = objNotesdb.GetView("($Drafts)")
vec = view.GetAllUnreadEntries()
But for GetAllUnreadEntries() I am getting Object doesn't support this property or method
You can get all unread documents from the Inbox by using the GetAllUnreadEntries method in the NotesView class. The result will be returned as a NotesViewEntryCollection object.
I am working on a very, very simple project which sets a followup Flag on a selected message when running a macro.
I have created this so far which works very nicely, but I want to improve it by replacing the manual input of "YA" initials and put the default profile user initials as the initials.
I have found the contactitem object, but I have no idea how to get the initials out of it to put it as a .FlagRequest
Any idea's about this?
This is currently my code: (the GetCurrentItem just returns the selected email)
Public Sub SetCustomFlagNormal()
Dim objMsg As Object
Set objMsg = GetCurrentItem()
With objMsg
.MarkAsTask olMarkThisWeek
.TaskDueDate = Now
.FlagRequest = "YA"
.ReminderSet = True
.ReminderTime = Now + 2
.Save
End With
Set objMsg = Nothing
End Sub
The Outlook object model provides the CurrentUser property for the Namespace and Account classes. The property of the Namespace class returns the display name of the currently logged-on user as a Recipient object.
Sub DisplayCurrentUser()
Dim myNamespace As Outlook.NameSpace
Set myNameSpace = Application.GetNameSpace("MAPI")
MsgBox myNameSpace.CurrentUser
End Sub
The property of the Account class returns a Recipient object that represents the current user identity for the account. See the Name property of the Recipient class.
I have finally found a way.
After getting to multiple website, I was able to determine that Outlook doesn't offer a way to get the user initials and that Word has to be called upon to get the initials
As office uses the same initials throughout all office applications.
I got my response on this website.
http://blogs.technet.com/b/heyscriptingguy/archive/2008/03/18/how-can-i-retrieve-the-user-name-and-user-initials-from-microsoft-powerpoint.aspx
Hope it helps
We're on exchange 2007 and I'm using php-ews and I want to get a list of all the bookings for a room resource. By room resource, I mean the rooms button in outlook when creating a meeting invite.
The code I have so far returns items from my calendar but I need calendar from 'Conference room A'. Anyone have done this?
$host = 'mailhost';
$username = 'xxxx';
$password = 'xxxx';
$mail = 'xxxx';
$startDateEvent = "2013-01-14T09:00:00";
$endDateEvent = "2013-09-20T17:00:00";
$ews = new ExchangeWebServices($host, $username, $password);
$request = new EWSType_FindItemType();
$request->Traversal = EWSType_FolderQueryTraversalType::SHALLOW;
$request->CalendarView->StartDate = $startDateEvent;
$request->CalendarView->EndDate = $endDateEvent;
$request->CalendarView->MaxEntriesReturned = 100;
$request->CalendarView->MaxEntriesReturnedSpecified = true;
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $mail;
$response = $ews->FindItem($request);
echo '<pre>'.print_r($response, true).'</pre>';
I'm even later to the game. But The way I solved this was to create an exchange account after the name of the room, for instance boardroom#.
Then I got people to copy in boardroom# whenever they sent out a meeting request. My scripts simply interrogate boardroom#'s calendar. Everyone at the organisation has a copy of boardroom's calendar in read-only mode that they can look at to see all the meetings that week.
My software was for a display sign outside the room that showed whether the room was in use or not based upon this calendar.
Late to the game but maybe this will help someone....
Basically, php-ews never added the GetRooms operation. You could modify your app to perform the room lookup via ldap (assuming your rooms exist in AD) and then use the email address of each room and query it's calendar using impersonation.
See my answer here...
https://stackoverflow.com/a/23815914/2979715
I'm trying to build a custom form for a joomla website that allows users to complete some fields and attach a document that will be sent to an email address I can specify.
Does anyone know of any good components or plugins for accomplishing this ?
$from: This is the the email address that the email will look like it is coming from.
$fromname: This is the name of the person or organization this email is coming from.
$recipient: This is the email address (or array of email addresses) that the email will be going to.
$subject: This is the Subject of the email.
$body: The is the message body of the email.
$mode: Set this to 1 for HTML email, set it to 0 for text email. This field is optional.
$cc: This is the email address (or array of email addresses) that the email will be Carbon Copied to. This field is optional.
$bcc: This is the email address (or array of email addresses) that the email will be Blind Carbon Copied to. This field is optional.
$attachment: This is the full path and filename (or array of full paths and filenames) of the files that you wish to attach to the email. This field is optional.
$replyto: This is the the email address that the email will go to if the recipient clicks reply. This field is optional.
$replytoname: This is the name of the person or organization this email will go to if the recipient clicks reply. This field is optional.
Now that you know how that works, let's look at an example!
$from = 'admin#somewhere.com';
$fromname = 'BIGSHOT Blog';
$recipient[] = 'john#somewhere.com';
$recipient[] = 'jane#somewhere.com';
$subject = 'Want to learn about BIGSHOT Blog';
$body = '<p>Check us out!</p><p>http://www.somewhere.com</p>';
$mode = 1;
$cc = 'bob#somewhereelse.com';
$bcc[] = 'simon#somewhereelse.com';
$bcc[] = 'nick#somewhereelse.com';
$attachment[] = '/home/my_site/public_html/images/stories/food/coffee.jpg';
$attachment[] = '/home/my_site/public_html/images/stories/food/milk.jpg';
$replyto = 'no_reply#somewhere.com';
$replytoname = 'NO REPLY - BIGSHOT Blog';
JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname);
You can use JUtility::sendMail to send an email in Joomla with attachment.For more information how to use go to this link.
JUtility/sendMail
A little more digging on the joomla extensions directory and I think I found what I need: http://extensions.joomla.org/extensions/contacts-and-feedback/contact-forms/11494