Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:04:54+00:00 2026-06-18T03:04:54+00:00

Trying to send email through methods. I have a method addHeader: headername with: aString

  • 0

Trying to send email through methods.
I have a method

addHeader: headername with: aString 
|email|
email:= aString.
'To'= headername ifTrue[ self message: 'To:', with ].    
 'From'= headername ifTrue[ self message: 'From:', with].
 'Subject'= headername ifTrue[  self message:'Subject', with].

My question was Workspace

addHeader:'To' with:'abcde@gmail.com'. 

addHeader:'From' with:'efg@gmail.com'  

When i execute above code one by one. All these values should be added to this method.

 message: aString 
 "Recieves To: abcde@gmail.com"
  ^ message
 "next time when it recieves From: efg@gmail.com. How can i concatenate 
   both earlier String and current String"

How to get this result

'To: abcde@gmail.com
From: efg@gmail.com'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:04:55+00:00Added an answer on June 18, 2026 at 3:04 am

    I’m not really sure I got exactly what you are trying to do. Anyway, let’s suppose that you want to send a mail specifying the sender, the subject, and so on. There are different ways you can do this, but in every case you have to keep the state between different calls of your method, and this is done by defining an instance variable (or more variables, depending on the way you choose to follow). If you want to keep the signature of your method, i.e. to keep using a single method to add different parts of the header, you could use a single var containing a Dictionary.

    This can be done defining a Header class containing a single instance variable that will contain a Dictionary, for instance headerDictionary. This var has to be initialized in a class method new as follows:

    new
    
        headerDictionary := Dictionary new.
    

    At this point your addHeader:email: method can simply put values in the dictionary as follows, without if’s or external methods (BTW I wouldn’t call it addHeader:email:, since for instance the value for Subject is not an email, but these are just bells and whistles):

    addHeader: headerName email: aString
    
        headerDictionary at: headerName put: aString.
    

    In this way in your workspace you can execute the following lines and end up with the dictionary contained in hdr containing the values you want:

    hdr := Header new.
    hdr addHeader:'To' email:'abcde@gmail.com'.
    hdr addHeader:'From' email:'efg@gmail.com'.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send an email through php. I have tried sending to
I'm trying to send an email through the Facebook API. I've added the application
I am trying to send an email through the result sets generated in MySQL
I am trying to send email using smtp authentication through google but I am
Possible Duplicate: Sending email in .NET through Gmail I am trying to send a
I am trying to send an attachment through AWS Simple Email Service, and i
I am trying to send email using gmail from my mvc application. I am
I am trying to send email using Exchange 2007 from a console app using
I was trying to send email through Appcelerator Cloud Service, in my Titanium app.
I get a no method error when trying to send out email with ActionMailer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.